iOS 13 beta4 no longer gives
1) PHImageFileURLKey 2) PHImageResultIsDegradedKey in image result info keys.
Anyone knows a way to find the fileurl of the P
You have to use this function from PHAsset object:
- (PHContentEditingInputRequestID)requestContentEditingInputWithOptions:(nullable PHContentEditingInputRequestOptions *)options completionHandler:(void (^)(PHContentEditingInput *__nullable contentEditingInput, NSDictionary *info))completionHandler;
Then you can retrieve URL this way:
NSURL *url = contentEditingInput.fullSizeImageURL;
Some example Objective-C code for anyone else looking for it:
PHContentEditingInputRequestOptions *editOptions = [[PHContentEditingInputRequestOptions alloc] init];
[myPHAsset requestContentEditingInputWithOptions:editOptions completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
if (contentEditingInput.fullSizeImageURL) {
//do something with contentEditingInput.fullSizeImageURL
}
}];
With the suggestion of guhan0, I made a small change. Indeed, sometimes, there are more than 1 "fileURL:...", so, I take the first when the value start with "file://" which means there is a file url. I think there is a better solution, but for now, it works well:
private func getFileURLFromPHAssetResource(resourceDescription description: String) -> String? {
let regex = try! NSRegularExpression(pattern: "(?<=fileURL: ).*(?=\\s)")
for match in regex.matches(in: description, options: [], range: NSRange(location: 0, length: description.count)).lazy {
let url = String(description[Range(match.range, in: description)!])
if url.starts(with: "file://") { return url }
}
return nil
}