[英]How to access other attributes/columns from a parse.com object after pulling the object from parse (swift)
I am pulling code from parse using the query below. 我正在使用下面的查询从解析中提取代码。 I retrieve the objects but I can only access "object.objectId" if I try "object.name" and "name" is a column on the Funlists table my app crashes and I get this error: "Thread 1:EXC_BAD_INSTRUCTION(code=EXC_1286_INVOP, subcode=0x0)"
我检索了对象,但是如果我尝试“ object.name”并且“ name”是Funlists表上的列,则我的应用程序崩溃了,我只能访问“ object.objectId”,并且出现此错误:“线程1:EXC_BAD_INSTRUCTION(code = 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()
}
}
You probably have to access to the entity properties using dictionary-like syntax, like: 您可能必须使用类似于字典的语法访问实体属性,例如:
object["name"]
I presume that the error happens here: 我认为错误发生在这里:
self.funlists.append(object.name)
I would change that to: 我将其更改为:
self.funlists.append(object["name"])
or 要么
self.funlists.append(object["name"] as String)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.