Skip to content

Commit b03da01

Browse files
authored
Merge d3f15d1 into 0ac301b
2 parents 0ac301b + d3f15d1 commit b03da01

File tree

34 files changed

+1115
-160
lines changed

34 files changed

+1115
-160
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Parse-Swift Changelog
22

33
### main
4-
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.1.6...main)
4+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.1.7...main)
55
* _Contributing to this repo? Add info about your change here to be included in the next release_
66

7+
### 1.1.7
8+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.1.6...1.1.7)
9+
710
__New features__
11+
- Add transaction support to batch saveAll and deleteAll ([#89](https://github.com/parse-community/Parse-Swift/pull/89)), thanks to [Corey Baker](https://github.com/cbaker6).
812
- Add modifiers to containsString, hasPrefix, hasSuffix ([#85](https://github.com/parse-community/Parse-Swift/pull/85)), thanks to [Corey Baker](https://github.com/cbaker6).
913

1014
__Improvements__

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
2+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
3+
//: in the `File Inspector` is `Platform = macOS`. This is because
4+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
5+
//: be set to build for `macOS` unless specified.
6+
17
import PlaygroundSupport
28
import Foundation
39
import ParseSwift
@@ -38,7 +44,7 @@ let score = GameScore(score: 10)
3844
let score2 = GameScore(score: 3)
3945

4046
/*: Save asynchronously (preferred way) - Performs work on background
41-
queue and returns to designated on designated callbackQueue.
47+
queue and returns to specified callbackQueue.
4248
If no callbackQueue is specified it returns to main queue.
4349
*/
4450
score.save { result in
@@ -101,6 +107,29 @@ var score2ForFetchedLater: GameScore?
101107
}
102108
}
103109

110+
//: Saving multiple GameScores at once using a transaction.
111+
[score, score2].saveAll(transaction: true) { results in
112+
switch results {
113+
case .success(let otherResults):
114+
var index = 0
115+
otherResults.forEach { otherResult in
116+
switch otherResult {
117+
case .success(let savedScore):
118+
print("Saved \"\(savedScore.className)\" with score \(savedScore.score) successfully")
119+
if index == 1 {
120+
score2ForFetchedLater = savedScore
121+
}
122+
index += 1
123+
case .failure(let error):
124+
assertionFailure("Error saving: \(error)")
125+
}
126+
}
127+
128+
case .failure(let error):
129+
assertionFailure("Error saving: \(error)")
130+
}
131+
}
132+
104133
//: Save synchronously (not preferred - all operations on main queue).
105134
let savedScore: GameScore?
106135
do {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (iOS) and targeting
4+
//: an iPhone, iPod, or iPad. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = iOS`. This is because
6+
//: SwiftUI in macOS Playgrounds doesn't seem to build correctly
7+
//: Be sure to switch your target and `Playground Settings` back to
8+
//: macOS after leaving this page.
9+
310
import PlaygroundSupport
411
import Foundation
512
import ParseSwift

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift

ParseSwift.playground/Pages/14 - Config.xcplaygroundpage/Contents.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift
@@ -31,9 +37,9 @@ var query = GameScore.query("score" > 50,
3137
"createdAt" > afterDate)
3238
.order([.descending("score")])
3339

34-
// Query asynchronously (preferred way) - Performs work on background
35-
// queue and returns to designated on designated callbackQueue.
36-
// If no callbackQueue is specified it returns to main queue.
40+
//: Query asynchronously (preferred way) - Performs work on background
41+
//: queue and returns to specified callbackQueue.
42+
//: If no callbackQueue is specified it returns to main queue.
3743
query.limit(2).find(callbackQueue: .main) { results in
3844
switch results {
3945
case .success(let scores):
@@ -50,7 +56,7 @@ query.limit(2).find(callbackQueue: .main) { results in
5056
}
5157
}
5258

53-
// Query synchronously (not preferred - all operations on main queue).
59+
//: Query synchronously (not preferred - all operations on main queue).
5460
let results = try query.find()
5561
assert(results.count >= 1)
5662
results.forEach { (score) in
@@ -59,9 +65,9 @@ results.forEach { (score) in
5965
print("Found score: \(score)")
6066
}
6167

62-
// Query first asynchronously (preferred way) - Performs work on background
63-
// queue and returns to designated on designated callbackQueue.
64-
// If no callbackQueue is specified it returns to main queue.
68+
//: Query first asynchronously (preferred way) - Performs work on background
69+
//: queue and returns to specified callbackQueue.
70+
//: If no callbackQueue is specified it returns to main queue.
6571
query.first { results in
6672
switch results {
6773
case .success(let score):

ParseSwift.playground/Pages/3 - User - Sign Up.xcplaygroundpage/Contents.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
PlaygroundPage.current.needsIndefiniteExecution = true
@@ -25,7 +31,7 @@ struct User: ParseUser {
2531
}
2632

2733
/*: Sign up user asynchronously - Performs work on background
28-
queue and returns to designated on designated callbackQueue.
34+
queue and returns to specified callbackQueue.
2935
If no callbackQueue is specified it returns to main queue.
3036
*/
3137
User.signup(username: "hello", password: "world") { results in

ParseSwift.playground/Pages/4 - User - Continued.xcplaygroundpage/Contents.swift

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift
@@ -47,24 +53,6 @@ struct GameScore: ParseObject {
4753
}
4854
}
4955

50-
/*: Save your first customKey value to your `ParseUser`
51-
Asynchrounously - Performs work on background
52-
queue and returns to designated on designated callbackQueue.
53-
If no callbackQueue is specified it returns to main queue.
54-
*/
55-
User.current?.customKey = "myCustom"
56-
User.current?.score = GameScore(score: 12)
57-
User.current?.targetScore = GameScore(score: 100)
58-
User.current?.save { results in
59-
60-
switch results {
61-
case .success(let updatedUser):
62-
print("Successfully save custom fields of User to ParseServer: \(updatedUser)")
63-
case .failure(let error):
64-
print("Failed to update user: \(error)")
65-
}
66-
}
67-
6856
//: Logging out - synchronously
6957
do {
7058
try User.logout()
@@ -74,7 +62,7 @@ do {
7462
}
7563

7664
/*: Login - asynchronously - Performs work on background
77-
queue and returns to designated on designated callbackQueue.
65+
queue and returns to specified callbackQueue.
7866
If no callbackQueue is specified it returns to main queue.
7967
*/
8068
User.login(username: "hello", password: "world") { results in
@@ -94,9 +82,27 @@ User.login(username: "hello", password: "world") { results in
9482
}
9583
}
9684

85+
/*: Save your first `customKey` value to your `ParseUser`
86+
Asynchrounously - Performs work on background
87+
queue and returns to specified callbackQueue.
88+
If no callbackQueue is specified it returns to main queue.
89+
*/
90+
User.current?.customKey = "myCustom"
91+
User.current?.score = GameScore(score: 12)
92+
User.current?.targetScore = GameScore(score: 100)
93+
User.current?.save { results in
94+
95+
switch results {
96+
case .success(let updatedUser):
97+
print("Successfully save custom fields of User to ParseServer: \(updatedUser)")
98+
case .failure(let error):
99+
print("Failed to update user: \(error)")
100+
}
101+
}
102+
97103
//: Looking at the output of user from the previous login, it only has
98-
//: a pointer to the `score`and `targetScore` fields. You can fetch using `include` to
99-
//: get the score.
104+
//: a pointer to the `score` and `targetScore` fields. You can
105+
//: fetch using `include` to get the score.
100106
User.current?.fetch(includeKeys: ["score"]) { result in
101107
switch result {
102108
case .success:

ParseSwift.playground/Pages/5 - ACL.xcplaygroundpage/Contents.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift
@@ -40,7 +46,7 @@ var score = GameScore(score: 40)
4046
score.ACL = try? ParseACL.defaultACL()
4147

4248
/*: Save asynchronously (preferred way) - Performs work on background
43-
queue and returns to designated on designated callbackQueue.
49+
queue and returns to specified callbackQueue.
4450
If no callbackQueue is specified it returns to main queue.
4551
*/
4652
score.save { result in

ParseSwift.playground/Pages/6 - Installation.xcplaygroundpage/Contents.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift
@@ -34,7 +40,7 @@ struct Installation: ParseInstallation {
3440
//: WARNING: All calls on Installation need to be done on the main queue
3541
DispatchQueue.main.async {
3642

37-
/*: Save your first customKey value to your `ParseInstallation`.
43+
/*: Save your first `customKey` value to your `ParseInstallation`.
3844
Performs work on background queue and returns to designated on
3945
designated callbackQueue. If no callbackQueue is specified it
4046
returns to main queue.

ParseSwift.playground/Pages/7 - GeoPoint.xcplaygroundpage/Contents.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//: [Previous](@previous)
22

3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
39
import PlaygroundSupport
410
import Foundation
511
import ParseSwift
@@ -29,7 +35,7 @@ var score = GameScore(score: 10)
2935
score.location = ParseGeoPoint(latitude: 40.0, longitude: -30.0)
3036

3137
/*: Save asynchronously (preferred way) - performs work on background
32-
queue and returns to designated on designated callbackQueue.
38+
queue and returns to specified callbackQueue.
3339
If no callbackQueue is specified it returns to main queue.
3440
*/
3541
score.save { result in

0 commit comments

Comments
 (0)