在我用相机拍照后,我使用以下代码保存图像:
- UIImageWriteToSavedPhotosAlbum(image,self,"image:didFinishSavingWithError:contextInfo:",nil)
这样可以将图像保存在相机胶卷中.此外,我想将URL保存到Core Data中保存的图像.是否可以检索URL(或路径),以便我只需要保存此URL而不是Core Data中的完整图像?
解决方法
在阅读了在ObjectivC中编写的大量答案后,我终于想出了如何使用Xcode 6.2在Swift中编写这个:
- ALAssetsLibrary().writeImageToSavedPhotosAlbum(image.CGImage,orientation: ALAssetOrientation(rawValue: image.imageOrientation.rawValue)!,completionBlock:{ (path:NSURL!,error:NSError!) -> Void in
- println("\(path)")
- })