3 ms·
I love Firebase, but the Swift code in the iOS guide is of really low quality. For example (https://firebase.google.com/docs/database/ios/save-data#delete_data
by timjver 10y ago
I love Firebase, but the Swift code in the iOS guide is of really low quality. For example (https://firebase.google.com/docs/database/ios/save-data#delete_data https://firebase.google.com/docs/database/ios/save-data#dele...):
if currentData.value != nil, let uid = FIRAuth.auth()?.currentUser?.uid {
var post = currentData.value as! [String : AnyObject]
var stars : Dictionary<String, Bool>
stars = post["stars"] as? Dictionary<String, Bool> ?? [:]
// ...
}
What this should really be:
guard let post = currentData.value as? [String : AnyObject],
uid = FIRAuth.auth()?.currentUser?.uid else { return FIRTransactionResult.successWithValue(currentData) }
let stars = post["stars"] as? [String : Bool] ?? [:]
// ...
}
- ianbarber 10y agoGreat suggestion! Pull requests welcome as well if you have time: https://github.com/firebase/quickstart-ios/blob/master/database/DatabaseExampleSwift/PostTableViewCell.swift#L50 https://github.com/firebase/quickstart-ios/blob/master/datab...
- timjver 10y agoOh cool, I already sent feedback through the Firebase website but I'll do this as well.