我已经使用此代码通过openin菜单打开从其他应用程序导入的其他文件 但问题是,当我尝试在导入文件后删除框文件夹时,它会给我许可错误
-(void)openImportedFile:(NSURL *)url{
NSFileManager *filemanager=[NSFileManager defaultManager];
NSString *strfilepath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSString *inboxPath=[strfilepath stringByAppendingPathComponent:@"NewDocument"];
[filemanager createDirectoryAtPath:inboxPath withIntermediateDirectories:TRUE attributes:nil error:nil];
NSString *strInboxFilepath=[url path];
NSString *strdesPath=[inboxPath stringByAppendingPathComponent:[strInboxFilepath lastPathComponent]];
[self performSelector:@selector(deleteInboxFolder) withObject:nil afterDelay:0.5];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:strdesPath]];
self.docController.delegate = self;
[self.docController presentPreviewAnimated:YES];
}
这是删除收件箱文件夹的代码
-(void)deleteInboxFolder
{
NSFileManager *fm=[NSFileManager defaultManager];
NSError *error;
NSString *strfilepath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSString *path = [NSString stringWithFormat:@"%@/Inbox",strfilepath];
[fm removeItemAtPath:path error:&error];
if(error){
NSLog(@"%@",error);
}
}
我收到以下错误
Error Domain=NSCocoaErrorDomain Code=513 "The operation couldn’t be completed. (Cocoa error 513.)" UserInfo=0x16d5e7f0 {NSUnderlyingError=0x16d5e6d0 "The operation couldn’t be completed. Operation not permitted", NSFilePath=/var/mobile/Applications/D1252FCA-A496-45EE-80FC-4F6692AF4545/Documents/Inbox, NSUserStringVariant=(
Remove
)}
我很困惑该怎么做 请建议我解决方案 在此先感谢