2011-12-15 3 views
0

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 
+0

당신은 코드 줄을 게시 할 수 있습니다 어디 정확한 전자 오류가 표시되었습니다 ... –

+0

당신은 아마 어떤 것도] 또는 다른 하나를 추가, 어떤 코드 줄이이 오류를 제공합니까? –

+0

''[updateLabel'의''dateLabel setText :''''''''''''누락 된 것으로 보입니다. 기본적으로'[dateLabel setText : [[...]];' – luastoned

답변

2
[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' ]]; 

언밸런스 괄호는?

1

나는이 하나라고 생각하니?

[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' ]]; 

당신은 첫 번째 부분에서 열려 세 [NSString 전에 만 가까운 두 그들의 결국을한다. 당신은 쉼표를 놓치고있는 NSString 전에 너무 많은 열 브래킷을 가지고 있었다

[dateLabel setText:[NSString stringWithFormat:@"%d%@ %d%@ %d%@ %d%@ %d%@" , [components month], @"m", [components day], @"d" , [components hour], @"h" , [components minute], @"m" , [components second], @"s"]]; 

: 당신이 처음에 한 번 [너무 많은이 실제로

[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' ]]; 
0

을 원하는이 줄 구문 오류가있는 것처럼이 보인다.

0

어디에서 오류가 발생합니까? 여기 쉼표

'm' [components day] 

그것이

편집 도움이되기를 바랍니다 잊었처럼

[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' ]]; 

보인다 : 나는 여기에있을 것 같아요

을 너무 "["1 거기 많은 전에 NSString