[英]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.