0
下面的代碼給我的錯誤「'AnyObject'不能轉換爲'字符串'」在我把我的「if let」語句解開的行從Parse中提取的可選productData。我只是想從Parse中的對象中拉出一個String。我已到處檢查,所有標準答案/解決方案都無法正常工作。有什麼想法嗎?'AnyObject'不能轉換爲'字符串',而解包可選
大部分代碼是直接取自解析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)
}
}
}
是你的問題解決了還是你有更多的問題?如果有,請選擇其中一個答案。如果沒有,請告訴我,我會盡力幫忙。 –