Skip to content

Commit 378b81a

Browse files
authored
docs: improve organization of SDK config (#409)
* docs: improve organization of SDK config * update playgrounds
1 parent 62553bc commit 378b81a

File tree

23 files changed

+198
-76
lines changed

23 files changed

+198
-76
lines changed

ParseSwift.playground/Pages/1 - Your first Object.xcplaygroundpage/Contents.swift

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ struct GameScore: ParseObject {
4141
//: Your own properties.
4242
var points: Int?
4343

44-
//: Implement your own version of merge
44+
/*:
45+
Optional - implement your own version of merge
46+
for faster decoding after updating your `ParseObject`.
47+
*/
4548
func merge(with object: Self) throws -> Self {
4649
var updated = try mergeParse(with: object)
4750
if updated.shouldRestoreKey(\.points,
@@ -79,7 +82,10 @@ struct GameData: ParseObject {
7982
//: or else you will need your masterKey to force an upgrade.
8083
var bytes: ParseBytes?
8184

82-
//: Implement your own version of merge
85+
/*:
86+
Optional - implement your own version of merge
87+
for faster decoding after updating your `ParseObject`.
88+
*/
8389
func merge(with object: Self) throws -> Self {
8490
var updated = try mergeParse(with: object)
8591
if shouldRestoreKey(\.polygon,
@@ -120,10 +126,13 @@ score.save { result in
120126
assert(savedScore.updatedAt != nil)
121127
assert(savedScore.points == 10)
122128

123-
/*: To modify, need to make it a var as the value type
124-
was initialized as immutable. Using `mergeable`
125-
allows you to only send the updated keys to the
126-
parse server as opposed to the whole object.
129+
/*:
130+
To modify, you need to make it a var as the value type
131+
was initialized as immutable. Using `mergeable`
132+
allows you to only send the updated keys to the
133+
parse server as opposed to the whole object. Make sure
134+
to call `mergeable` before you begin
135+
your first mutation of your `ParseObject`.
127136
*/
128137
var changedScore = savedScore.mergeable
129138
changedScore.points = 200
@@ -210,15 +219,18 @@ assert(savedScore?.createdAt != nil)
210219
assert(savedScore?.updatedAt != nil)
211220
assert(savedScore?.points == 10)
212221

213-
/*: To modify, need to make it a var as the value type
214-
was initialized as immutable. Using `mergeable`
215-
allows you to only send the updated keys to the
216-
parse server as opposed to the whole object.
222+
/*:
223+
To modify, you need to make a mutable copy of `savedScore`.
224+
Instead of using `mergeable` this time, we will use the `set()`
225+
method which allows us to accomplish the same thing
226+
as `mergeable`. You can choose to use `set()` or
227+
`mergeable` as long as you use either before you begin
228+
your first mutation of your `ParseObject`.
217229
*/
218-
guard var changedScore = savedScore?.mergeable else {
230+
guard var changedScore = savedScore else {
219231
fatalError("Should have produced mutable changedScore")
220232
}
221-
changedScore.points = 200
233+
changedScore = changedScore.set(\.points, to: 200)
222234

223235
let savedChangedScore: GameScore?
224236
do {

ParseSwift.playground/Pages/10 - Cloud Code.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ struct GameScore: ParseObject {
144144
//: Your own properties.
145145
var points: Int?
146146

147-
//: Implement your own version of merge
147+
/*:
148+
Optional - implement your own version of merge
149+
for faster decoding after updating your `ParseObject`.
150+
*/
148151
func merge(with object: Self) throws -> Self {
149152
var updated = try mergeParse(with: object)
150153
if updated.shouldRestoreKey(\.points,

ParseSwift.playground/Pages/11 - LiveQuery.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ struct GameScore: ParseObject {
2323
var location: ParseGeoPoint?
2424
var name: String?
2525

26-
//: Implement your own version of merge
26+
/*:
27+
Optional - implement your own version of merge
28+
for faster decoding after updating your `ParseObject`.
29+
*/
2730
func merge(with object: Self) throws -> Self {
2831
var updated = try mergeParse(with: object)
2932
if updated.shouldRestoreKey(\.points,

ParseSwift.playground/Pages/12 - Roles and Relations.xcplaygroundpage/Contents.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ struct User: ParseUser {
3232
var customKey: String?
3333
var scores: ParseRelation<Self>?
3434

35-
//: Implement your own version of merge
35+
/*:
36+
Optional - implement your own version of merge
37+
for faster decoding after updating your `ParseObject`.
38+
*/
3639
func merge(with object: Self) throws -> Self {
3740
var updated = try mergeParse(with: object)
3841
if updated.shouldRestoreKey(\.customKey,
@@ -55,7 +58,10 @@ struct Role<RoleUser: ParseUser>: ParseRole {
5558
//: Provided by Role.
5659
var name: String?
5760

58-
//: Implement your own version of merge
61+
/*:
62+
Optional - implement your own version of merge
63+
for faster decoding after updating your `ParseObject`.
64+
*/
5965
func merge(with object: Self) throws -> Self {
6066
var updated = try mergeParse(with: object)
6167
if updated.shouldRestoreKey(\.name,
@@ -78,7 +84,10 @@ struct GameScore: ParseObject {
7884
//: Your own properties.
7985
var points: Int?
8086

81-
//: Implement your own version of merge
87+
/*:
88+
Optional - implement your own version of merge
89+
for faster decoding after updating your `ParseObject`.
90+
*/
8291
func merge(with object: Self) throws -> Self {
8392
var updated = try mergeParse(with: object)
8493
if updated.shouldRestoreKey(\.points,

ParseSwift.playground/Pages/13 - Operations.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ struct GameScore: ParseObject {
2525
var points: Int?
2626
var name: String?
2727

28-
//: Implement your own version of merge
28+
/*:
29+
Optional - implement your own version of merge
30+
for faster decoding after updating your `ParseObject`.
31+
*/
2932
func merge(with object: Self) throws -> Self {
3033
var updated = try mergeParse(with: object)
3134
if updated.shouldRestoreKey(\.points,

ParseSwift.playground/Pages/15 - Custom ObjectId.xcplaygroundpage/Contents.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ struct GameScore: ParseObject {
3434
//: Your own properties.
3535
var points: Int?
3636

37-
//: Implement your own version of merge
37+
/*:
38+
Optional - implement your own version of merge
39+
for faster decoding after updating your `ParseObject`.
40+
*/
3841
func merge(with object: Self) throws -> Self {
3942
var updated = try mergeParse(with: object)
4043
if updated.shouldRestoreKey(\.points,
@@ -79,10 +82,11 @@ score.save { result in
7982
//: Any changes to `createdAt` and `objectId` will not be saved to the server.
8083
print("Saved score: \(savedScore)")
8184

82-
/*: To modify, need to make it a var as the value type
83-
was initialized as immutable. Using `.mergeable`
84-
allows you to only send the updated keys to the
85-
parse server as opposed to the whole object.
85+
/*:
86+
To modify, need to make it a var as the value type
87+
was initialized as immutable. Using `.mergeable` or `set()`
88+
allows you to only send the updated keys to the
89+
parse server as opposed to the whole object.
8690
*/
8791
var changedScore = savedScore.mergeable
8892
changedScore.points = 200

ParseSwift.playground/Pages/17 - SwiftUI - Finding Objects.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ struct GameScore: ParseObject {
3333
var name: String?
3434
var myFiles: [ParseFile]?
3535

36-
//: Implement your own version of merge
36+
/*:
37+
Optional - implement your own version of merge
38+
for faster decoding after updating your `ParseObject`.
39+
*/
3740
func merge(with object: Self) throws -> Self {
3841
var updated = try mergeParse(with: object)
3942
if updated.shouldRestoreKey(\.points,

ParseSwift.playground/Pages/18 - SwiftUI - Finding Objects With Custom ViewModel.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ struct GameScore: ParseObject {
3333
var location: ParseGeoPoint?
3434
var name: String?
3535

36-
//: Implement your own version of merge
36+
/*:
37+
Optional - implement your own version of merge
38+
for faster decoding after updating your `ParseObject`.
39+
*/
3740
func merge(with object: Self) throws -> Self {
3841
var updated = try mergeParse(with: object)
3942
if updated.shouldRestoreKey(\.points,

ParseSwift.playground/Pages/19 - SwiftUI - LiveQuery.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ struct GameScore: ParseObject {
3131
var location: ParseGeoPoint?
3232
var name: String?
3333

34-
//: Implement your own version of merge
34+
/*:
35+
Optional - implement your own version of merge
36+
for faster decoding after updating your `ParseObject`.
37+
*/
3538
func merge(with object: Self) throws -> Self {
3639
var updated = try mergeParse(with: object)
3740
if updated.shouldRestoreKey(\.points,

ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ struct GameScore: ParseObject {
2626
var oldScore: Int?
2727
var isHighest: Bool?
2828

29-
//: Implement your own version of merge
29+
/*:
30+
Optional - implement your own version of merge
31+
for faster decoding after updating your `ParseObject`.
32+
*/
3033
func merge(with object: Self) throws -> Self {
3134
var updated = try mergeParse(with: object)
3235
if updated.shouldRestoreKey(\.points,

0 commit comments

Comments
 (0)