迅速に作業し、スウィフト3にスウィフト2プロジェクトを変換しないで、他のコードはうまく動作しますが、runTransactionBlock
が動作していないと、このエラーを検出しました:Firebase runTransactionBlockはXcodeの8を更新した後、3
"runTransactionBlock: usage detected while persistence is enabled. Please be aware that transactions will not be persisted across app restarts"
何ができますか違う? Firebase SDKのバージョン
Firebase 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)
}
}
マイfirebase SDKのバージョンも3.0.1です – Jelly