【发布时间】:2015-09-08 01:56:16
【问题描述】:
下面的代码在我放置“if let”语句以解开从 Parse 提取的可选 productData 的行处给出错误“'AnyObject' 不可转换为 'String'”。我只是想从 Parse 中的一个对象中提取一个字符串。我到处检查过,所有标准答案/解决方案都不起作用。有什么想法吗?
大部分代码直接取自 Parse iOS 文档Here
import Foundation
import Parse
func getDataFromParse () {
var productDataFromParse = PFQuery(className:"Product")
productDataFromParse.getObjectInBackgroundWithId("uyeXHufDgq") {
(productData: PFObject?, error: NSError?) -> Void in
if error == nil && productData != nil {
if let productTitle = productData["productTitle"] as! String {
self.productTitle = productTitle
}
} else {
println(error)
}
}
}
【问题讨论】:
-
您的问题解决了吗,还是还有其他问题?如果有,请选择其中一个答案。如果没有,请告诉我,我会尽力提供帮助。
标签: ios swift parse-platform