更新Xcode 8并将Swift 2项目转换为Swift 3后,其他代码运行良好,但runTransactionBlock
无法正常工作,发现此错误:
"runTransactionBlock:在启用持久性时检测到使用情况.请注意,应用程序重新启动时不会保留事务"
可能有什么不对?
Firebase runTransaction Code
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 …
Run Code Online (Sandbox Code Playgroud)