Swift错误:whereKey和NSArrays

时间:2015-06-16 21:53:58

标签: ios iphone swift

使用Swift创建iOS应用程序。我遇到了以下似乎无法解决的错误。帮助赞赏。

   override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell {
    let cell: HonkHonkTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath!) as! HonkHonkTableViewCell

    let honkHonk: PFObject = self.timelineData.objectAtIndex(indexPath!.row) as! PFObject

    cell.honkTextView.text = honkHonk.objectForKey("content") as! String

    var dataFormatter: NSDateFormatter = NSDateFormatter()
    dataFormatter.dateFormat = "MM-dd MM:mm"
    cell.timeStampLabel.text = dataFormatter.stringFromDate(honkHonk.createdAt!)

    var findUser: PFQuery = PFUser.query()!
    findUser.whereKey(key: "objectId", equalTo: honkHonk.objectForKey("user")!.objectId)

    findUser.findObjectsInBackgroundWithBlock{
        (objects:[AnyObject]?, error:NSError?) -> Void in
        if error == nil {
            let user: PFUser = (objects as! NSArray).lastObject as! PFUser
            cell.usernameLabel.text = user.username
        }
    }

    // Configure the cell...

    return cell
}

错误:

  • 无法调用whereKey
  • 从AnyObject转换为NSArray始终失败

0 个答案:

没有答案