[英]Update the createdAt column in Parse.com
当需要上传文件到Parse.com
的createdAt
列获取设置自动。
我想将createdAt
时间更新为该功能的当前时间:
let query = PFQuery(className:"NorgeStory")
query.getObjectInBackgroundWithId(objID[(indexPath?.row)!]) {
(gameScore: PFObject?, error: NSError?) -> Void in
if error != nil {
print(error)
} else if let gameScore = gameScore {
gameScore["isPending"] = false
gameScore["createdAt"] = self.currentDateTime
gameScore.saveInBackground()
gameScore.saveInBackgroundWithBlock({ (success: Bool, error: NSError?) in
if (success) {
// The score key has been incremented
print("Accepted post!")
let alert = UIAlertView()
alert.title = "Innlegg godkjennt!"
alert.message = "Innlegget er godkjennt."
alert.addButtonWithTitle("OK")
alert.show()
self.queryStory()
} else {
// There was a problem, check error.description
print(error?.description)
}
})
}
}
self.currentDateTime
来自: let currentDateTime = NSDate()
但是不知何故, createdAt
根本不会改变。 有小费吗?
您无法更新createdAt
字段(请参阅此Parse论坛链接 ,其中Parse员工说“ createdAt和updatedAt字段无法手动修改”。您应该创建一个新的Date列,而应进行更新。
我很抱歉,但是场createdAt
和updatedAt
不能手动修改; https://www.parse.com/questions/can-i-modify-the-field-createdat
尝试这样的事情:
modifiedAt
作为NSDate
。 gameScore["createdAt"]
更改为gameScore["modifiedAt"]
。 现在,该字段将被更新为与createdAt
相同的格式,并且您可以根据需要轻松地更新列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.