2011-10-23 2 views
0

저는 초보 개발자입니다. 이 오류로 인해 멈췄습니다.Clang LLVM 1.0 오류 objective-c

Clang LLVM 1.0 Error 
Expected ':' 

line: [pipe fileHandleForReading availableData] 

아무도 도와 줄 수 있습니까? 미리 감사드립니다.

- (NSInteger)sizeOfItemAtPath:(NSString*)path { 
    BOOL isdir; 
    [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isdir]; 
    if (isdir) { 
     NSPipe *pipe = [NSPipe pipe]; 
     NSTask *t = [[[NSTask alloc] init] autorelease]; 
     [t setLaunchPath:@"/usr/bin/du"]; 
     [t setArguments:[NSArray arrayWithObjects:@"-k", @"-d", @"0", path, nil]]; 

     [t setStandardOutput:pipe]; 
     [t setStandardError:[NSPipe pipe]]; 
     [t launch]; 
     [t waitUntilExit]; 

     NSString *sizeString = [[[NSString alloc] initWithData:[[pipe fileHandleForReading availableData] encoding:NSASCIIStringEncoding] autorelease]; 
     sizeString = [[sizeString componentsSeparatedByString:@" "] objectAtIndex:0]; 
     BOOL bytes; 
     bytes = [sizeString longLongValue]*1024; 
    } 
    else { 
     BOOL bytes; 
     bytes = [[[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil] fileSize]; 
    } 
    BOOL bytes; 
    return bytes; 
} 

답변

3

을 당신이 누락되어 ] : 또한

NSString *sizeString = [[[NSString alloc] initWithData:[[pipe fileHandleForReading] availableData] encoding:NSASCIIStringEncoding] autorelease]; 

: 그것은 전체 라인은 다음과 같이 할 필요가

[[pipe fileHandleForReading] availableData] 

해야합니다 , 당신의 방법은 돌아올 것이다. 쓰레기. 그 이유는 bytes을 세 번 정의했기 때문입니다. if 분기에 한 번, else 분기에 한 번, 그리고 묶는 방법 본문에 한 번. 반환 값은 마지막 값에서 가져 오지만이 값은 초기화됩니다. 뿐만 아니라 잘못된 유형을 사용하고 있습니다. 이 아니라 NSInteger bytes;이어야합니다. 정의를 메소드의 시작 부분에두고 다른 모든 정의를 제거해야 할 경우 변수는 한 번만 존재할 수 있습니다.

+0

고마워요! 나는 그 문제를 해결했다. – Giovanni

0

이 시도 :

[[pipe fileHandleForReading] availableData]