验证从UIImagePickerController获取的NSURL

时间:2012-03-24 20:07:29

标签: iphone ipad uiimagepickercontroller nsurl

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {    

    NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];
}

我正在获取此图片网址然后我将其保存在NSUserDefaults并关闭我的应用程序。然后我在下一次app运行时从iPhone相册中删除带有此URL的图片我从用户deafults获取imageUrl。现在我需要决定这个图像是否存在。我怎么能找到这个。

1 个答案:

答案 0 :(得分:0)

NSString *path = [imageURL path];
if ([[NSFileManager defaultManager] fileExistsAtPath:path])     //Does file exist?
{
  //Do something if the file exists or handle the case where it doesn't
}

希望这会有所帮助 噬细胞