Я строю свое первое приложение для iPhone и iPad, это простое приложение, которое учитывает данные, относящиеся к данному месяцу, дате, часу, минуте и секунде.Count Down Application giving Ожидаемая ошибка «]»
После фиксации несколько ошибок это наткнулся на следующую ошибку:
Expected "]"
Вот код:
#import "ViewController.h"
@implementation ViewController
-(void)updateLabel {
NSCalendar *calender = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
int units = NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *components = [calender components:units fromDate:[NSDate date] toDate:destinationDate options:0 ];
[dateLabel setText:[[NSString stringWithFormat:@"%d%c %d%c %d%c %d%c %d%c" , [components month], 'm' [components day], 'd' , [components hour], 'h' , [components minute], 'm' , [components second], 's' ]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
destinationDate = [[NSDate dateWithTimeIntervalSince1970:1325153549] retain];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector (updateLabel) userInfo:nil repeats:YES];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
@end
Вы можете разместить строку кода, где точное e rror показано ... –
, вы, вероятно, пропустили какой-либо] или добавили еще один, какая строка кода дает эту ошибку? –
Кажется, что строка, начинающаяся с '[dateLabel setText:' в 'updateLabel', отсутствует' '' 'у вас в основном' [dateLabel setText: [[...]]; ' – luastoned