我正在尝试使用 NSTask 将二进制 plist 转换为 xml,尽管遇到了我不太理解的错误。如果我接受命令 NSTask 失败并将其复制到命令行,它就可以正常工作。希望有人能告诉我什么是错的。
NSString *defaultPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Preferences/com.defaults.plist"];
task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/plutil"];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: @"-convert xml1", defaultPath, nil];
// using `@"-convert", "xml1", defaultPath, nil` doesn't seem to work either.
[task setArguments: arguments];
NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[task launch];
[task waitUntilExit];
[task release];
NSLog
/usr/bin/plutil (
"-convert xml1",
"/Users/Mira/Library/Preferences/com.defaults.plist"
)
unrecognized option: -convert xml1