我使用下面的查询从解析中提取代码。我检索对象,但我只能访问" object.objectId"如果我尝试" object.name"和"名称"是Funlists表上的一列,我的应用程序崩溃,我收到此错误:"线程1:EXC_BAD_INSTRUCTION(代码= EXC_1286_INVOP,子代码= 0x0)"
var query = PFQuery(className: "FunLists")
query.whereKey("createdBy", equalTo:"Sean Plott")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
// The find succeeded.
NSLog("Successfully retrieved \(objects.count) scores.")
// Do something with the found objects
for object in objects {
NSLog("%@", object.objectId)
self.funlists.append(object.name)
}
} else {
// Log details of the failure
NSLog("Error: %@ %@", error, error.userInfo!)
}
dispatch_async(dispatch_get_main_queue()) {
self.tableView.reloadData()
}
}
答案 0 :(得分:1)
您可能必须使用类似字典的语法来访问实体属性,例如:
object["name"]
我认为错误发生在这里:
self.funlists.append(object.name)
我会改为:
self.funlists.append(object["name"])
或
self.funlists.append(object["name"] as String)