I'm trying to use NSTask to convert a binary plist to xml, although run into an error that I don't quite understand. If I take the command NSTask fails on and copy it to the command line it works just fine. Hopefully someone can tell me what is wrong.
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