File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
ParseSwift.playground/Pages/15 - Custom ObjectId.xcplaygroundpage Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ struct GameScore: ParseObject {
36
36
self . objectId = objectId
37
37
self . score = score
38
38
}
39
+
40
+ init ( objectId: String ) {
41
+ self . objectId = objectId
42
+ }
39
43
}
40
44
41
45
//: Define initial GameScore this time with custom `objectId`.
@@ -101,14 +105,16 @@ query.first { result in
101
105
}
102
106
}
103
107
104
- //: Query object
105
- let query = GameScore . query ( " objectId " == " myObjectId " )
106
- query. find { result in
108
+ //: Now we will attempt to fetch a ParseObject that isn't saved.
109
+ let scoreToFetch = GameScore ( objectId: " hello " )
110
+
111
+ //: Asynchronously (preferred way) fetch this GameScore based on it's objectId alone.
112
+ scoreToFetch. fetch { result in
107
113
switch result {
108
- case . success( let found ) :
109
- print ( found )
114
+ case . success( let fetchedScore ) :
115
+ print ( " Successfully fetched: \( fetchedScore ) " )
110
116
case . failure( let error) :
111
- print ( error)
117
+ assertionFailure ( " Error fetching: \( error) " )
112
118
}
113
119
}
114
120
You can’t perform that action at this time.
0 commit comments