2010-05-29 3 views
0

xcode iphone보기 기반 응용 프로그램에서 무한 while 루프를 컴파일하려고하면 예상 식별자 또는 '('before 'while'을 읽는 동안 오류가 발생합니다. 당신은 코드의 이미지를보고 싶다면 가능한 한. 사진. 코드 블록에 대해 죄송합니다. 작동하지 않는, 여기에 링크입니다. http://www.freeimagehosting.net/uploads/931d5d8788.gifwhile 루프를 컴파일 할 때 오류 메시지가 발생했습니다.

#import "Lockerz_NotifierViewController.h" 

@implementation Lockerz_NotifierViewController 
NSMutableData *responseData; 

while (1) { 
    NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://amicionline.me"] 
               cachePolicy:NSURLRequestUseProtocolCachePolicy 
              timeoutInterval:60.0]; 
    // create a connection 
    NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 

    if(theConnection) { 
     // create the datum 
     responseData=[[NSMutableData data] retain]; 
    } else { 
     // code this later 
    } 
} 

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 
{ 
    [responseData setLength:0]; 
} 

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 
    // make it work 
    NSLog(@"Succeeded! Received %d bytes of data:",[responseData length]); 

    // release it 
    [connection release]; 
    [responseData release]; 

} 
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 
    [responseData appendData:data]; 
} 
+0

이것은 전체 파일입니까? – LB40

+0

예, 전체 파일을 게시하십시오. 이 코드는 결코 컴파일되지 않지만 while 루프는 상수에 할당 할 수 없으므로 1 = 1은 C에서 유효하지 않습니다. 무한 루프의 경우 while (1) 또는 for (;;) 중 하나를 수행 할 수 있습니다. –

답변

0

당신이 뭘 하려는지? 당신은 쓸 수 없습니다 코드를 @implementation에 직접 입력해야합니다. 예를 들어 다음과 같이 메서드에 입력해야합니다.

-(void)start { 
    while (1) { 
    ... 
    } 
} 
관련 문제