iPhone 및 iPad 용 첫 번째 응용 프로그램을 작성 중이며 주어진 월, 일,시, 분 및 초로 계산되는 간단한 응용 프로그램입니다.카운트 다운 응용 프로그램에서 예상되는 "]"오류 발생
오류의 몇 가지를 수정 한 후이는 다음과 같은 오류를 건너 왔어요 :
다음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
당신은 코드 줄을 게시 할 수 있습니다 어디 정확한 전자 오류가 표시되었습니다 ... –
당신은 아마 어떤 것도] 또는 다른 하나를 추가, 어떤 코드 줄이이 오류를 제공합니까? –
''[updateLabel'의''dateLabel setText :''''''''''''누락 된 것으로 보입니다. 기본적으로'[dateLabel setText : [[...]];' – luastoned