我試圖開發一個基於分析的排序社交網絡,並且遇到了試圖爲每個「組」創建投票系統的問題。在我的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