I noticed that there are a lot of questions in Obj-C, but I hardly remember Obj-C, and each of the answers was specific to the question. Here I get this error: “There is no pointer path to use the table cell” sometimes when the application is updated. I notice that when I do not update, but leave and reopen the table view, the formatting is destroyed.
Here is my update method, which is used in several places:
@IBAction func loadData(){ timeLineData.removeAllObjects() //pulls the data from the server var findTimeLineData: PFQuery = PFQuery(className: "Sweets") findTimeLineData.findObjectsInBackgroundWithBlock{ (objects:[AnyObject]!, error: NSError!) -> Void in if !error{ for object:PFObject! in objects{ self.timeLineData.addObject(object) } let tempArray: NSArray = self.timeLineData.reverseObjectEnumerator().allObjects self.timeLineData = tempArray as NSMutableArray //reloads the data in the table view self.tableView.reloadData() } } }
And the tableview method:
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? { let cell: SweetTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as SweetTableViewCell let sweet: PFObject = self.timeLineData.objectAtIndex(indexPath.row) as PFObject //part of the animation cell.sweetTextView.alpha = 0 cell.userNameLabel.alpha = 0 cell.timestampLabel.alpha = 0 cell.sweetTextView.text = sweet.objectForKey("content") as String //add the date var dateFormatter: NSDateFormatter = NSDateFormatter() dateFormatter.dateFormat = "HH:mm yyyy-MM-dd" cell.timestampLabel.text = dateFormatter.stringFromDate(sweet.createdAt) //finds the sweeter associated with a pointer var findSweeter: PFQuery = PFUser.query() findSweeter.whereKey("objectId", equalTo: sweet.objectForKey("sweeter").objectId) findSweeter.findObjectsInBackgroundWithBlock{ (objects: [AnyObject]!, error: NSError!)-> Void in if !error{ let user: PFUser = (objects as NSArray).lastObject as PFUser cell.userNameLabel.text = user.username } } //adds animation UIView.animateWithDuration(1, animations: { cell.sweetTextView.alpha = 1 cell.userNameLabel.alpha = 1 cell.timestampLabel.alpha = 1 }) return cell }
Any idea what causes the error?
source share