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 {
3636 self . objectId = objectId
3737 self . score = score
3838 }
39+
40+ init ( objectId: String ) {
41+ self . objectId = objectId
42+ }
3943}
4044
4145//: Define initial GameScore this time with custom `objectId`.
@@ -101,14 +105,16 @@ query.first { result in
101105 }
102106}
103107
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
107113 switch result {
108- case . success( let found ) :
109- print ( found )
114+ case . success( let fetchedScore ) :
115+ print ( " Successfully fetched: \( fetchedScore ) " )
110116 case . failure( let error) :
111- print ( error)
117+ assertionFailure ( " Error fetching: \( error) " )
112118 }
113119}
114120
You can’t perform that action at this time.
0 commit comments