gpt4 book ai didi

swift - 如何显示用户在提要上发布消息的时间?

转载 作者:行者123 更新时间:2023-11-28 06:56:35 26 4
gpt4 key购买 nike

我通过将我的 TableViewController 子类化为 PFQueryTableViewController,创建了一个有点像 facebook 和 twitter 的新闻提要。我希望用户看到某人在提要上发布消息的确切时间,但我的 PFTableViewCell 中的代码写错了。基本上我想从 Parse 中检索日期(或“createdAt”)。无论如何我可以显示用户通过 Parse 发布的时间吗?

下面是我的代码:

    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
}

}

最佳答案

我想通了!

下面是我的代码:

 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

关于swift - 如何显示用户在提要上发布消息的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33454347/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com