1
NSString* getExePath()
{
char buf[0] = {0};
uint32_t size = 0;
_NSGetExecutablePath(buf,&size);
char* path = (char*)malloc(size+1);
path[size] = 0;
_NSGetExecutablePath(path,&size);
char* pCur = strrchr(path, '/');
*pCur = 0;
NSString* nsPath = [NSString stringWithUTF8String:path];
free(path);
path = NULL;
return nsPath;
}
执行命令脚本
void runSystemCommand(NSString *cmd)
{
[[NSTask launchedTaskWithLaunchPath:@"/bin/sh"
arguments:@[@"-c", cmd]]
waitUntilExit];
}
runSystemCommand(@"python /Users/1.py");