我的应用程序在 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/32501627/