2014-12-04 80 views
0

我使用下面的查询从解析中拉取代码。我检索的对象,但我只能访问“object.objectId”,如果我尝试“object.name”和“名称”是Funlists表上的列我的应用程序崩溃,我得到这个错误:“线程1:EXC_BAD_INSTRUCTION(code = EXC_1286_INVOP,子码=为0x0)”如何从parse.com对象中解析对象后,访问其他属性/列(swift)

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() 
      } 
     } 

回答

1

你可能有使用字典的语法,就像进入到实体属性:

object["name"] 

我推测错误发生在这里:

self.funlists.append(object.name) 

我会改变,要:

self.funlists.append(object["name"]) 

self.funlists.append(object["name"] as String) 
+0

感谢安东尼奥! “对象[”名称“]作为字符串”工作我会尽快接受你的回答,stackoverflow说我必须等待8分钟。大声笑 – Adim 2014-12-04 17:36:21