将文件上传到Parse.com
时,createdAt
列会自动设置。
我想将createdAt
时间更新为此func设置的当前时间:
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
根本没有变化......怎么样?有什么提示吗?
答案 0 :(得分:1)
您无法更新createdAt
字段(请参阅this Parse forum link,其中Parse员工说“createdAt和updatedAt字段无法手动修改”。您应该创建一个更新的新Date列代替。
答案 1 :(得分:1)
对不起,但无法手动修改字段createdAt
和updatedAt
; https://www.parse.com/questions/can-i-modify-the-field-createdat
尝试这样的事情:
modifiedAt
NSDate
。gameScore["createdAt"]
更改为gameScore["modifiedAt"]
。现在该字段将以与createdAt
相同的格式更新,您可以根据需要轻松更新列。