中查詢用戶名,這是新增iOS版本,並使用教程開發Twitter應用程序(如應用程序)。無法從解析iOS Swift
人們可以從他們的帳戶發送推文。並顯示在主頁上。
此刻到主頁的所有推文和一切運作良好,除了用戶名。即時得到零
這是我曾嘗試
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell:SpreadTableViewCell = tableView!.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! SpreadTableViewCell
let spread:PFObject = self.LiveFeedData.objectAtIndex(indexPath.row) as! PFObject
//----------This Content Works fine ----------------
cell.spreadTextView.text = spread.objectForKey("content") as! String
//Spreader
var findSpreader:PFQuery = PFUser.query()!
findSpreader.whereKey("objectId", equalTo: spread.objectForKey("spreader")!)
findSpreader.findObjectsInBackgroundWithBlock{
(objects:[AnyObject]?, error:NSError?)-> Void in
if error==nil{
let user = (objects as! [PFUser]).last
//but this one giving me nil
cell.username.text = user?.username
}
}
return cell
}
什麼數據結構傳播的? – Swinny89
@ Swinny89更新了代碼 – chathura
例如,如果錯誤不是零,你應該做一些事情 - 例如打印它。然而,你可以簡化你的代碼,你的記錄中的'spreader'值是一個PFUser,所以你可以使用'fetchInBackgroundWithBlock'來讀取它,而不是運行一個find。 – Paulw11