2014-12-04 84 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