我试图开发一个基于分析的排序社交网络,并且遇到了试图为每个“组”创建投票系统的问题。在我的TableViewController中,使用PFQueryTableViewController,我收到错误“Use of unresolved identifier'object'”。这里是我工作的部分使用未解析的标识符'object'Xcode 6 Swift
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as GroupTableViewCell
group:PFObject = self.timelineData.objectAtIndex(indexPath.row) as PFObject
cell.groupTextView.alpha = 0
cell.timeStampLabel.alpha = 0
cell.UserNameLabel.alpha = 0
cell.groupTextView.text = group.objectForKey("content") as String
var dataFormatter:NSDateFormatter = NSDateFormatter()
dataFormatter.dateFormat = "MM/DD/yyyy HH:mm"
cell.timeStampLabel.text = dataFormatter.stringFromDate(group.createdAt)
let score = object.valueForKey("count") as? Int
cell.count.text = "\(score)"
cell.groupTextView.text = object.valueForKey("content") as? String
var findUser:PFQuery = PFUser.query()
findUser.whereKey("objectId", equalTo: group.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
UIView.animateWithDuration(0.5, animations: {
cell.groupTextView.alpha = 1
cell.timeStampLabel.alpha = 1
cell.UserNameLabel.alpha = 1
如果有人知道这里的问题是什么,请帮助开发者的初学者。
添加另一种方法从评论的完整性和格式:
override func objectAtIndexPath(indexPath: NSIndexPath!) -> PFObject! {
var object : PFObject? = nil
if(indexPath.row < self.objects.count) {
object = self.objects[indexPath.row] as? PFObject
}
return object
}
哪一行会导致错误,并且该行的'object'声明在哪里? – 2015-01-27 00:36:54