Created
July 18, 2015 16:26
-
-
Save jonathan-beebe/ac60ef8278efe7340a8f to your computer and use it in GitHub Desktop.
Convert ALAsset to iOS8+ PHAsset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Its from ALAsset to PHAsset.
How can i convert AVAsset to PHAsset ?
Thanks you