ios - PFObject 值可能没有类 : _SwiftValue
<p><p>我们正在试用<code>Parse server</code>,我们之前从未使用过Parse SDK。
作为学习的一部分,我们尝试了 <code>Facebook login with Parse</code>,效果很好。接下来我们想保存检索到的用户信息,但我们一直在保存<code>Profile picture</code>。</p>
<p><strong>守则</strong></p>
<pre><code>let pictureURL = "https://graph.facebook.com/\(facebookID)/picture?type=large&return_ssl_resources=1"
let imageData = NSData.init(contentsOf: NSURL(string: pictureURL) as! URL)
let picture = PFFile(data: imageData! as Data)
PFUser.current()?.setObject(picture, forKey: "profilePicture")
PFUser.current()?.saveInBackground()
</code></pre>
<p>它在 <code>setObject</code> 行崩溃,日志如下:</p>
<p> <a href="/image/h8I60.png" rel="noreferrer noopener nofollow"><img src="/image/h8I60.png" alt="crash log - image"/></a> </p>
<p>非常感谢任何帮助以解决此问题。谢谢!</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>当你将可选的东西传递给 <code>Any</code> 时会发生这种情况。</p>
<p>试试这个:</p>
<pre><code> if let picture = PFFile(data: imageData! as Data) {
PFUser.current()?.setObject(picture, forKey: "profilePicture")
PFUser.current()?.saveInBackground()
}
</code></pre>
<p>或者简单地说,如果您确定 <code>picture</code> 永远不会为零:</p>
<pre><code> let picture = PFFile(data: imageData! as Data)
PFUser.current()?.setObject(picture!, forKey: "profilePicture")
PFUser.current()?.saveInBackground()
</code></pre></p>
<p style="font-size: 20px;">关于ios - PFObject 值可能没有类 : _SwiftValue,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/39509300/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/39509300/
</a>
</p>
页:
[1]