In iOS 8, with the new PhotoKit, the way to create a new image is with -[PHPhotoLibrary performChanges:completionHandler]
, in this way:
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
// TODO set metadata?
} completionHandler:^(BOOL success, NSError *error) {
if(success)
{
// do stuff
}
}];
However, I can't find any documentation on how to set metadata on the image.
In the old ALAssetLibrary (which still works, and may still be the 'correct' way going forward), you would just use -[ALAssetLibrary writePhotoToSavedPhotosAlbum:metadata:completionBlock:]
, which allows you to pass in a metadata dictionary.
Is there an equivalent method in PhotoKit?
You can achieve the same result by using a temporary file. For example:
I'm copying-pasting code from my project, hopefully I'm not missing something.