title: iOS 9 save photo with custom filename using PHPhotoLibrary and swift 2
body: <p>I'm trying to save a photo with a custom filename using the iOS 9 PHAssetCreationRequest with .addResourceWithType and Swift 2. It is saving the photo ok but it's not using the filename I specify in the PHAssetResourceCreationOptions options. I want to use a custom filename as I need to store a custom string with the photo which indicates what 'type' of photo it is. At the moment I am storing the 'type' along with its localIdentifier in a Core Data store, however, if the app is uninstalled so is the Core Data store so I'm looking for an additional method that stays with the photo.
  Here is the code I'm using:</p>
  
  <pre><code>var assetPlaceholder:PHObjectPlaceholder!
  PHPhotoLibrary.sharedPhotoLibrary().performChanges({
      if #available(iOS 9.0, *) {
          let options = PHAssetResourceCreationOptions()
          options.originalFilename = frameType + "_" + origFilename
          let newcreation:PHAssetCreationRequest = PHAssetCreationRequest.creationRequestForAsset()
          newcreation.addResourceWithType(PHAssetResourceType.Photo, data:UIImageJPEGRepresentation(image, 1)!, options: options)
          assetPlaceholder = newcreation.placeholderForCreatedAsset
      } else { // &lt; ios 9
          // Fallback on earlier versions
          let assetChangeRequest = PHAssetChangeRequest.creationRequestForAssetFromImage(image)    
          assetPlaceholder = assetChangeRequest.placeholderForCreatedAsset      
      }
      let albumChangeRequest = PHAssetCollectionChangeRequest(forAssetCollection: assetCollection)
      albumChangeRequest!.addAssets([assetPlaceholder])
  }, completionHandler: {(success:Bool, error:NSError?) in
  </code></pre>