爲什麼我無法將來自Object中的「ObjectId」作爲一個String在swift中呈現,即使它自然是一個字符串?這裏是邏輯我一個嘗試使用:如何從解析中的對象中獲取ObjectId並將其作爲字符串在swift中呈現
//MARK: Fetch ObjectId Strings From Parse
func fetchObjectIdString() {
let query = PFQuery(className: "Books")
query.whereKey("genreName", equalTo: self.genreName)
query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if error == nil {
if let objects = objects as [PFObject]! {
for oneObj in objects {
let ObjectIdFromParse = oneObj["objectId"] as! String
let SingleObjectId = SixthBook()
SingleObjectId.objectIdString = ObjectIdFromParse
self.arrayOfObjectId.append(SingleObjectId)
}
}
} else {
// Log details of the failure
print("Error: \(error!) \(error!.userInfo)")
}
}
}
也能正常工作的所有其他字符串列除的ObjectId我解析的對象。它每次都會引發異常錯誤。爲什麼是這樣?