在Swift中UIImageWriteToSavedPhotosAlbum之后的图像的URL [英] URL of image after UIImageWriteToSavedPhotosAlbum in Swift

查看:86
本文介绍了在Swift中UIImageWriteToSavedPhotosAlbum之后的图像的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我用相机拍照后,我使用以下代码保存图像:

After i took a photo with the camera i save the image with the following code:

UIImageWriteToSavedPhotosAlbum(image, self,"image:didFinishSavingWithError:contextInfo:", nil)

这会将图像保存在相机胶卷中。此外,我想将URL保存到Core Data中保存的图像。是否可以检索URL(或路径)以便我只需要保存此URL而不是Core Data中的完整图像?

This saves the image in the camera roll. Additionally i want to save the URL to this saved image in Core Data. Is it possible to retrieve the URL (or the Path) to so that i only need to save this URL and not the full image in Core Data?

推荐答案

在阅读了很多用ObjectivC编写的答案后,我终于想出了如何用Xcode 6.2在Swift中写这个:

After reading a lot of answers written in ObjectivC i finally figured out how to write this in Swift with Xcode 6.2:

ALAssetsLibrary().writeImageToSavedPhotosAlbum(image.CGImage, orientation: ALAssetOrientation(rawValue: image.imageOrientation.rawValue)!,
            completionBlock:{ (path:NSURL!, error:NSError!) -> Void in
                println("\(path)")
        })

这篇关于在Swift中UIImageWriteToSavedPhotosAlbum之后的图像的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆