工作更新的Xcode 8和轉換斯威夫特2項目進入迅捷3之後,其他代碼工作得很好,但runTransactionBlock
不工作,發現這個錯誤:火力地堡runTransactionBlock不迅速3
"runTransactionBlock: usage detected while persistence is enabled. Please be aware that transactions will not be persisted across app restarts"
可能是什麼錯誤?
火力地堡runTransaction代碼
postRef.runTransactionBlock({ (currentData: FIRMutableData) -> FIRTransactionResult in
if var post = currentData.value as? [String : AnyObject], let uid = FIRAuth.auth()?.currentUser?.uid {
var stars : Dictionary<String, Bool>
stars = post["likeMap"] as? [String : Bool] ?? [:]
var likeCount = post["likeCount"] as? Int ?? 0
if let _ = stars[uid] {
// Unstar the post and remove self from stars
likeCount -= 1
self._liked = false
stars.removeValue(forKey: uid)
} else {
// Star the post and add self to stars
likeCount += 1
self._liked = true
stars[uid] = true
}
post["likeCount"] = likeCount as AnyObject?
post["likeMap"] = stars as AnyObject?
self._likeCount = likeCount
// Set value and report transaction success
currentData.value = post
return FIRTransactionResult.success(withValue: currentData)
}
return FIRTransactionResult.success(withValue: currentData)
}) { (error, committed, snapshot) in
if let error = error {
print(error.localizedDescription)
}
}
我的火力SDK版本也是3.0.1 – Jelly