I am using PhotoKit to edit photos and I need to preserve the metadata from the original photo. To do so I save the metadata then provide it to the options
paramete
We are supposed to write the data for the new image to the URL we obtain via
let theExportURL = output.renderedContentURL
In my case i was doing this...
let outputData = UIImagePNGRepresentation(bakedImage)
And at runtime i was getting the error
Error Domain=NSCocoaErrorDomain Code=-1 "The operation couldn’t be completed. (Cocoa error -1.)
But when I started exporting the data like this...
let outputData = UIImageJPEGRepresentation(bakedImage, 1)
It worked. This is documented here ... https://developer.apple.com/library/prerelease/ios/documentation/Photos/Reference/PHContentEditingOutput_Class/index.html
and this same question has been answered here... https://stackoverflow.com/a/28362235