1

I've created a news feed sort of like facebook and twitter by subclassing my TableViewController into PFQueryTableViewController. I want users to see the exact time someone posted a message on the feed but the code in my PFTableViewCell is written incorrectly.Basically I want to retrieve the date(or "createdAt"" from Parse. Anyway I can show the users time posted through Parse?

Here is my code written below:

    override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?, object: PFObject!) -> PFTableViewCell? {
       let cell = tableView!.dequeueReusableCellWithIdentifier("BCell", forIndexPath: indexPath!) as! Post


    if let userPost : PFObject = self.posts.objectAtIndex(indexPath!.row) as! PFObject {

    cell.account.text = object["username"] as? String
    cell.tweet.text = object["message"] as? String
    cell.Time.text = "\((indexPath!.row + 1) * 3)m"
    cell.tweet.numberOfLines = 0
    let score = object[("count")] as! Int
    cell.favoriteCount.text = "\(score)"
    let replycnt = object["replies"] as! Int
    cell.replyCount.text = "\(replycnt) replies"
        if let profilePic = object["photo"] as? PFFile {
            cell.userImage.image = UIImage(named: "profileImage")
            //cell.userImage.file = profilePic
        }

        }
Bachenenad
  • 65
  • 7

1 Answers1

1

I figured it out!

Here is my code below:

 let dateUpdated = object.createdAt! as NSDate
let dateFormat = NSDateFormatter()
dateFormat.dateFormat = "MMM d, h:mm a"

cell.Time.text =  NSString(format: "%@", dateFormat.stringFromDate(dateUpdated)) as String
Bachenenad
  • 65
  • 7