我正在尝试将在文件夹名称中有空格的参数传递给NSTASK
. 但是,该命令没有成功执行,但是当我尝试在命令行上手动执行时,它工作正常。
NSMutableString* archive_path=[[NSMutableString alloc]init];
[archive_path appendString:@"/Users/user/desktop/one two/abc.mpkg"];
NSTask* tar_task = [[NSTask alloc]init];
tar_task.launchPath = @"/usr/sbin/pkgutil";
tar_task.arguments = @[@"--expand-full", archive_path, next_path];
tar_task.standardOutput = pipe;
[tar_task launch];
我尝试将所有字符串archive_path
放在双引号中,但它不起作用,我也尝试使用带有空格的转义字符,但它仍然不起作用。
archive_path1 = [archive_path stringByReplacingOccurrencesOfString:@" " withString:@"\\ "];
任何原因?