모든 /usr/bin/
명령의 디렉토리를 찾을 수있는 곳이 있습니까? 아이폰은 기술적으로 NSTask를 지원하지 않는다는 것을 압니다.하지만 이것은 교육적인 목적을위한 것이므로 NSTask.h를 가져 왔습니다. /usr/bin/cal
을 실행하면 정상적으로 작동하지만 /usr/bin/ls
에는 작동하지 않으며 그 이유는 알 수 없습니다./usr/bin/iPhone 용 터미널 명령
* 참고 :
는 아이폰 OS 이후NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/cal"]; //@"/usr/bin/ls" produces cannot find path error
NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[task launch];
NSData *data;
data = [file readDataToEndOfFile];
NSString *string;
string = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
label.numberOfLines=0;
label.text = string;
[label sizeToFit];
[string release];
[task release];
내 장치가 jailbroken입니다. 나는 그것을 언급하는 것을 잊었다. 고마워! – MrHappyAsthma