macApp createFileAtPath失败,我需要在哪里更改?
相同的代码
NSString * folderPath = @"/Users/shang/Downloads";
NSFileManager *manager = NSFileManager.defaultManager;
NSString *fileAtPath = [folderPath stringByAppendingPathComponent:@"BNRootModel0000.h"];
bool isSuccess = [manager createFileAtPath:fileAtPath contents:[@"22222" dataUsingEncoding:NSUTF8StringEncoding] attributes:nil];
bool isExist = [NSFileManager.defaultManager fileExistsAtPath:fileAtPath];
bool isWritable = [NSFileManager.defaultManager isWritableFileAtPath:fileAtPath];
NSLog(@"__%@_%@_%@", @(isWritable), @(isExist), @(isSuccess));
iphoneApp :
2019-06-21 09:00:25.535204+0800 wer[50978:8502261] __1_1_1
macApp :
2019-06-21 08:59:58.765259+0800 wwww[50969:8497251] __0_0_0我希望在macApp上工作,但实际情况是失败了
发布于 2019-06-21 10:50:36
这是一个权限问题。在项目中,功能->应用程序SandBox ->文件访问,更改您的需要,并正常工作!
https://stackoverflow.com/questions/56695641
复制相似问题