I am working on an app using Core Data which includes a Product file containing item description and image filename. In a previous version on a different platform this filename would contain something like “elephant.jpg” and its associated image would also be called “elephant.jpg”. In this way the data could be entered and validated off-line and then imported into the app.
Using IOS8 and the Photos framework I cannot do this as there appears to be no way of persistently attaching a name to a photo image. I have tried looking at the image metadata using :
PHImageManager.defaultManager().requestImageDataForAsset(asset, options: nil) {
imageData,dataUTI,orientation,info in
println("Info %@", info) }
However this returns info such as
/private/var/mobile/Media/PhotoData/PhotoCloudSharingData/8083971319/2cc2fcd0-d19b-4803-b34f-35a285bc1fab/100CLOUD/**IMG_0008.JPG**
where IMG_0008.JPG is not related to the original image.
I am currently getting partially around this by ensuring each image has a unique dateTime for its creationDate, storing this in the Product.fileName and using this to retrieve my image with
var fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "creationDate == %@", imageCreationDate) // use CreationDate in predicate
var assets = PHAsset.fetchAssetsInAssetCollection(rec, options: fetchOptions)
However this is difficult to manage, and not easy to create datafiles which can be exported as the image has to be matched to the file after it has been imported to the iPad.
My problem would be solved if I could only attach a name to the image on iPhoto on my Mac which persisted after I shared the images with iCloud Photo Sharing.
I will be very grateful for any suggestions !