我的应用程序在 Instagram 上分享照片,为此,它首先将其保存在临时目录中:
let writePath = NSTemporaryDirectory().stringByAppendingPathComponent("instagram.igo")
它可以在 Swift 1.2
上运行,但不能在 Swift 2.0
上运行。
给出的错误消息是:
stringByAppendingPathComponent is unavailable: use URLByAppendingPathComponent on NSURL instead.
最佳答案
看起来 stringByAppendingPathComponent
方法已在 Swift 2.0 中删除,因此错误消息建议使用:
let writePath = NSURL(fileURLWithPath: NSTemporaryDirectory()).URLByAppendingPathComponent("instagram.igo")
更新:
URLByAppendingPathComponent()
已被 appendingPathComponent()
取代,所以改为:
let writePath = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("instagram.igo")
关于ios - stringByAppendingPathComponent 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32914281/