我正在尝试查找带有路径的文件,然后使用 NSFileManager 类将其删除。确实返回一个字符串,所以[info objectForKey:UIImagePickerControllerMediaURL]
我不明白为什么它在有效参数上失败。
NSError *error;
NSFileManager *manager = [NSFileManager defaultManager];
NSURL *url = [[NSURL alloc] initWithString:[info
objectForKey:UIImagePickerControllerMediaURL]];
if ([manager isDeletableFileAtPath: [info
objectForKey:UIImagePickerControllerMediaURL]]) {
BOOL success = [manager removeItemAtURL:url error:&error];
if (!success) {
NSLog(@"Error removing file at path: %@", error.localizedDescription);
}
}
我得到这个错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException'
, reason: '-[NSURL length]: unrecognized selector sent to instance 0x175ede10'