iOS9.0弃用AssetsLibrary中部分API

hi:

    先给个官方链接:https://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/

    在iOS9.0中,失效的部分API如下:

Finding Assets
assetForURL(_:resultBlock:failureBlock:)(iOS 9.0)

Enumerating Assets
enumerateGroupsWithTypes(_:usingBlock:failureBlock:)(iOS 9.0)

Saving Assets
writeVideoAtPathToSavedPhotosAlbum(_:completionBlock:)(iOS 9.0)
videoAtPathIsCompatibleWithSavedPhotosAlbum(_:)(iOS 9.0)
writeImageToSavedPhotosAlbum(_:orientation:completionBlock:)(iOS 9.0)
writeImageDataToSavedPhotosAlbum(_:metadata:completionBlock:)(iOS 9.0)
writeImageToSavedPhotosAlbum(_:metadata:completionBlock:)(iOS 9.0)

Managing Asset Groups
addAssetsGroupAlbumWithName(_:resultBlock:failureBlock:)(iOS 9.0)
groupForURL(_:resultBlock:failureBlock:)(iOS 9.0)


    保存相册时,意外发现以上API弃用,但实际上,还可以使用。。。

    给出解决办法:    

PHPhotoLibrary.sharedPhotoLibrary().performChanges({ () -> Void in
            
            PHAssetChangeRequest.creationRequestForAssetFromImage(UIImage(CGImage: cgimg))
            
            }) { (success, error) -> Void in
                if success {
                    print("保存成功")
                }
        }


来自:http://stackoverflow.com/questions/33079698/how-can-i-convert-photo-or-video-from-camera-to-nsdata


你可能感兴趣的:(iOS9.0弃用AssetsLibrary中部分API)