0
下面的代碼工作正常,直到我升級到OSX Lion。它調用一個外部命令並將輸出保存到一個NSString中。NSTask檢索外部命令的輸出在Lion上停止woking
我不知道爲什麼它停止工作。有任何想法嗎?
-(NSString *) rawResponse{
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/sbin/scselect"];
NSPipe *pipe = [NSPipe pipe];
[task setStandardError:pipe];
[task launch];
NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile];
[task waitUntilExit];
[task release];
NSString *result = [[[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"The returned value is: %@", result);
return result;
}