2017-06-20 47 views

回答

0

NSStrings需要转换为C字符串,然后才能将它们包含在argv阵列中。

做到这一点:

NSString *bath =[NSString stringWithFormat:@"%@/path", path]; 
const char *cBath = [bath UTF8String]; 
if (cBath == NULL) 
{ 
    print("cBath is null ; why is path also null?"); 
    return; 
} 
pid_t pid; 
int status; 
const char *argv[] = {"mkdir", cBath, NULL}; 
posix_spawn(&pid, "/bin/mkdir", NULL, NULL, (char* const*)argv, NULL); 
waitpid(pid, &status, WEXITED);` 
+0

我得到这个错误现在https://imgur.com/gallery/Lggqu –

+0

我增加了一点错误检查。你应该确保洗澡是有效的。 –