Skip to content

Instantly share code, notes, and snippets.

@jonathan-beebe
Created July 18, 2015 16:26
Show Gist options
  • Save jonathan-beebe/ac60ef8278efe7340a8f to your computer and use it in GitHub Desktop.
Save jonathan-beebe/ac60ef8278efe7340a8f to your computer and use it in GitHub Desktop.
Convert ALAsset to iOS8+ PHAsset
import Photos
import AVFoundation
func ALAssetToPHAsset(asset:ALAsset) -> PHAsset {
var fetchOptions: PHFetchOptions = PHFetchOptions()
var url:NSURL = asset.valueForProperty(ALAssetPropertyAssetURL) as! NSURL
let fetchResult:PHFetchResult = PHAsset.fetchAssetsWithALAssetURLs([url], options: fetchOptions)
return fetchResult.firstObject as! PHAsset
}
@1170197998
Copy link

OK

@sanjukhunt
Copy link

Its from ALAsset to PHAsset.

How can i convert AVAsset to PHAsset ?

Thanks you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment