[英]Update the createdAt column in Parse.com
When uploading a file to Parse.com
, the createdAt
column get set automatic. 当需要上传文件到
Parse.com
的createdAt
列获取设置自动。
I want to update the createdAt
time, to the current time this func get set: 我想将
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)
}
})
}
}
The self.currentDateTime
is from: let currentDateTime = NSDate()
self.currentDateTime
来自: let currentDateTime = NSDate()
But somehow, the createdAt
does not change at all.. How come? 但是不知何故,
createdAt
根本不会改变。 Any tips? 有小费吗?
您无法更新createdAt
字段(请参阅此Parse论坛链接 ,其中Parse员工说“ createdAt和updatedAt字段无法手动修改”。您应该创建一个新的Date列,而应进行更新。
I am sorry, but the field createdAt
and updatedAt
cannot be modified manually; 我很抱歉,但是场
createdAt
和updatedAt
不能手动修改; https://www.parse.com/questions/can-i-modify-the-field-createdat https://www.parse.com/questions/can-i-modify-the-field-createdat
Try something like this: 尝试这样的事情:
modifiedAt
as an NSDate
. modifiedAt
作为NSDate
。 gameScore["createdAt"]
to gameScore["modifiedAt"]
. gameScore["createdAt"]
更改为gameScore["modifiedAt"]
。 Now that field will be updated as the same format as createdAt
, and you can easy update the column as you would like. 现在,该字段将被更新为与
createdAt
相同的格式,并且您可以根据需要轻松地更新列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.