Я запрашиваю объект PHContentEditingInput
, используя метод requestContentEditingInput
. Я вижу, что возвращаемый объект содержит непустое приватное поле _fullSizeImageURL
Однако fullSizeImageURL
свойство getter возвращает nil
.
let url = contentEditingInput!.fullSizeImageURL // fullSizeImageURL is nil
Обновление: Вот полный пример кода, воспроизводящий проблему:
var assetId: String? = nil
//Changes for the Photos Library must be maded within the performChanges block
PHPhotoLibrary.shared()
.performChanges({
//This will request a PHAsset be created for the UIImage
let creationRequest = PHAssetCreationRequest.creationRequestForAsset(from: image)
//Create a change request to insert the new PHAsset in the collection
let request = PHAssetCollectionChangeRequest(for: collection)
//Add the PHAsset placeholder into the creation request.
//The placeholder is used because the actual PHAsset hasn't been created yet
if request != nil && creationRequest.placeholderForCreatedAsset != nil {
request!.addAssets([creationRequest.placeholderForCreatedAsset!] as NSFastEnumeration)
}
assetId = creationRequest.placeholderForCreatedAsset?.localIdentifier
}, completionHandler: { (success: Bool, error: Error?) in
let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: [assetId!], options: nil)
fetchResult.enumerateObjects({ (asset: PHAsset, _, _) in
asset.requestContentEditingInput(with: PHContentEditingInputRequestOptions()) { (input, _) in
let url = input!.fullSizeImageURL
// **Returned url is nil, while private field input._fullSizeImageURL is NOT empty as shown on the screenshot above.**
}
})
}
)