I have an this URL file:///var/mobile/Media/DCIM/101APPLE/IMG_1426.JPG
. How do I get image from library with it?
I got that URL from the previous time run the app. Now I want to fetch only this image without fetching all image from library.
I tried to use:
if let url = URL(string: url) {
let imgData = NSData(contentsOf: url)
let image = UIImage(data: imgData! as Data)
}
But I got this error:
Error Domain=NSCocoaErrorDomain Code=257 "The file “IMG_1426.JPG” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/var/mobile/Media/DCIM/101APPLE/IMG_1426.JPG, NSUnderlyingError=0x28200bfc0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
I got URL from this:
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return true
}
self.requestContentEditingInput(with: options, completionHandler: {(contentEditingInput: PHContentEditingInput?, info: [AnyHashable : Any]) -> Void in
if let url = contentEditingInput?.fullSizeImageURL {
//this
}
})
I don't want to save that photo in my app documents, how to I achieve it? Or at least how do I open the Photo App with showing that image? Thanks.