转换项目后,我在 Swift 2 中收到以下错误:
stringByExpandingTildeinPath is unavailable: use stringByExpandingTildeinPath on NSString instead
这是我在 Swift 1.2 中用于与 whatsapp 共享的代码,第 3 行的错误:
let filename = "myimage.wai"
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, false)[0] as NSString
let destinationPath = documentsPath.stringByAppendingString("/" + filename).stringByExpandingTildeInPath
为什么要求它不扩展~
然后自己扩展呢?让 API 自己处理要简单得多:
let filename = "myimage.wai"
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
let destinationPath = documentsPath + "/" + filename
关于ios - stringByExpandingTildeinPath 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32635314/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |