2017-06-20 98 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

我增加了一點錯誤檢查。你應該確保洗澡是有效的。 –