ios - stringByExpandingTildeinPath 不可用
<p><p>转换项目后,我在 Swift 2 中收到以下错误:</p>
<pre><code>stringByExpandingTildeinPath is unavailable: use stringByExpandingTildeinPath on NSString instead
</code></pre>
<p>这是我在 Swift 1.2 中用于与 whatsapp 共享的代码,第 3 行的错误:</p>
<pre><code> let filename = "myimage.wai"
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, false) as NSString
let destinationPath = documentsPath.stringByAppendingString("/" + filename).stringByExpandingTildeInPath
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>为什么要求它不扩展<code>~</code>然后自己扩展呢?让 API 自己处理要简单得多:</p>
<pre><code>let filename = "myimage.wai"
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let destinationPath = documentsPath + "/" + filename
</code></pre></p>
<p style="font-size: 20px;">关于ios - stringByExpandingTildeinPath 不可用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/32635314/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/32635314/
</a>
</p>
页:
[1]