iOS8 Photos Framework: How to get the name(or filename) of a PHAsset?

I know the question has already been answered, but I figured I would provide another option: extension PHAsset { var originalFilename: String? { var fileName: String? if #available(iOS 9.0, *) { let resources = PHAssetResource.assetResources(for: self) if let resource = resources.first { fileName = resource.originalFilename } } if fileName == nil { /// This is … Read more

Save images with phimagemanager to custom album?

This is how I do: At the top: import Photos var image: UIImage! var assetCollection: PHAssetCollection! var albumFound : Bool = false var photosAsset: PHFetchResult! var assetThumbnailSize:CGSize! var collection: PHAssetCollection! var assetCollectionPlaceholder: PHObjectPlaceholder! Creating the album: func createAlbum() { //Get PHFetch Options let fetchOptions = PHFetchOptions() fetchOptions.predicate = NSPredicate(format: “title = %@”, “camcam”) let collection … Read more

How to get an ALAsset URL from a PHAsset?

Create the assetURL by leveraging the localidentifier of the PHAsset. Example: PHAsset.localidentifier returns 91B1C271-C617-49CE-A074-E391BA7F843F/L0/001 Now take the 32 first characters to build the assetURL, like: assets-library://asset/asset.JPG?id=91B1C271-C617-49CE-A074-E391BA7F843F&ext=JPG You might change the extension JPG depending on the UTI of the asset (requestImageDataForAsset returns the UTI), but in my testing the extensions of the assetURL seems to be … Read more