将NSURL转换为NSString [英] Convert an NSURL to an NSString

查看:128
本文介绍了将NSURL转换为NSString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,用户可以从内置的应用程序图像或从iPhone照片库中选择图像。我使用具有 NSString 属性的对象Occasion来保存 imagePath

I have an app where the user can choose an image either from the built-in app images or from the iphone photo library. I use an object Occasion that has an NSString property to save the imagePath.

现在,对于内置的应用程序图像,我确实将文件名称作为 NSString 保存在 [场合imagePath] 中。但是在用户从照片库中选择图像的第二种情况下,我得到一个 NSURL 我要将其转换为 NSString 能够将其保存在 [场合imagePath ]。

Now in the case of the built-in app images I do get the file name as an NSString an save in the [occasion imagePath]. But in the 2nd case where the user picks an image form the photo library I get an NSURL which I want to convert to an NSString to be able to save it in [occasion imagePath].

是否可以转换 NSURL NSString

推荐答案

NSString *myString = myURL.absoluteString;

docs

这篇关于将NSURL转换为NSString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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