aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/SwiftBuildTest/main.swift
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2017-12-18 21:05:07 -0800
committerGravatar GitHub <noreply@github.com>2017-12-18 21:05:07 -0800
commit52cdf0b25a12b5baed8546893634dab9c1a03e56 (patch)
tree2de151c370aabbe1721a56f7bda3d703534309e9 /Firestore/Example/SwiftBuildTest/main.swift
parent52c7329f2a74ad457898afebe21b1f02e35d0d0f (diff)
Clean up warnings (#578)
* Clean up warnings * Remove optional parens around ifs
Diffstat (limited to 'Firestore/Example/SwiftBuildTest/main.swift')
-rw-r--r--Firestore/Example/SwiftBuildTest/main.swift41
1 files changed, 21 insertions, 20 deletions
diff --git a/Firestore/Example/SwiftBuildTest/main.swift b/Firestore/Example/SwiftBuildTest/main.swift
index f62bf48..260735b 100644
--- a/Firestore/Example/SwiftBuildTest/main.swift
+++ b/Firestore/Example/SwiftBuildTest/main.swift
@@ -39,7 +39,7 @@ func main() {
listenToDocuments(matching: query);
- enableDisableNetwork(db: db);
+ enableDisableNetwork(database: db);
types();
}
@@ -133,7 +133,7 @@ func writeDocument(at docRef: DocumentReference) {
}
}
-func enableDisableNetwork(db db: Firestore) {
+func enableDisableNetwork(database db: Firestore) {
// closure syntax
db.disableNetwork(completion: { (error) in
if let e = error {
@@ -235,26 +235,27 @@ func readDocuments(matching query: Query) {
func listenToDocument(at docRef: DocumentReference) {
- let listener = docRef.addSnapshotListener() { document, error in
- if let error = error {
- print("Uh oh! Listen canceled: \(error)")
- return
- }
+ let listener = docRef.addSnapshotListener() { document, error in
+ if let error = error {
+ print("Uh oh! Listen canceled: \(error)")
+ return
+ }
- if let document = document {
- // Note that document.data() is nullable.
- let data : [String:Any]? = document.data()
- print("Current document: \(data)");
- if (document.metadata.isFromCache) {
- print("From Cache")
- } else {
- print("From Server")
- }
- }
+ if let document = document {
+ // Note that document.data() is nullable.
+ if let data : [String:Any] = document.data() {
+ print("Current document: \(data)");
+ }
+ if document.metadata.isFromCache {
+ print("From Cache")
+ } else {
+ print("From Server")
+ }
}
+ }
- // Unsubscribe.
- listener.remove();
+ // Unsubscribe.
+ listener.remove();
}
func listenToDocuments(matching query: Query) {
@@ -316,7 +317,7 @@ func transactions() {
let balanceA = try transaction.getDocument(accA)["balance"] as! Double
let balanceB = try transaction.getDocument(accB)["balance"] as! Double
- if (balanceA < amount) {
+ if balanceA < amount {
errorPointer?.pointee = NSError(domain: "Foo", code: 123, userInfo: nil)
return nil
}