Skip to content

Commit 7932ba7

Browse files
authored
Improve API documentation (#253)
* Improve API documentation * Add SwiftUI info to API docs
1 parent ee67405 commit 7932ba7

File tree

8 files changed

+68
-19
lines changed

8 files changed

+68
-19
lines changed

CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# Parse-Swift Changelog
22

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

7+
### 1.10.4
8+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.10.3...1.10.4)
9+
10+
__Improvements__
11+
- Improve documentation for ParseObject ([#253](https://github.com/parse-community/Parse-Swift/pull/253)), thanks to [Corey Baker](https://github.com/cbaker6).
12+
713
### 1.10.3
814
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.10.2...1.10.3)
915

1016
__Improvements__
11-
- Update documents to show new Swift 5.5 async/await methods ([#251](https://github.com/parse-community/Parse-Swift/pull/251)), thanks to [Corey Baker](https://github.com/cbaker6).
17+
- Update documents to show new Swift 5.5 async/await methods ([#252](https://github.com/parse-community/Parse-Swift/pull/252)), thanks to [Corey Baker](https://github.com/cbaker6).
1218

1319
### 1.10.2
1420
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.10.1...1.10.2)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ struct GameScore: ParseObject {
4343
/*:
4444
It's recommended the developer adds the emptyObject computed property or similar.
4545
Gets an empty version of the respective object. This can be used when you only need to update a
46-
a subset of the fields of an object as oppose to updating every field of an object.
47-
- note: Using an empty object and updating a subset of the fields reduces the amount of data sent between
46+
a subset of the fields of an object as oppose to updating every field of an object. Using an
47+
empty object and updating a subset of the fields reduces the amount of data sent between
4848
client and server when using `save` and `saveAll` to update objects.
4949
*/
5050
var emptyObject: Self {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ struct GameScore: ParseObject {
3434
/*:
3535
It's recommended the developer adds the emptyObject computed property or similar.
3636
Gets an empty version of the respective object. This can be used when you only need to update a
37-
a subset of the fields of an object as oppose to updating every field of an object.
38-
- note: Using an empty object and updating a subset of the fields reduces the amount of data sent between
37+
a subset of the fields of an object as oppose to updating every field of an object. Using an
38+
empty object and updating a subset of the fields reduces the amount of data sent between
3939
client and server when using `save` and `saveAll` to update objects.
4040
*/
4141
var emptyObject: Self {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ struct User: ParseUser {
3636
/*:
3737
It's recommended the developer adds the emptyObject computed property or similar.
3838
Gets an empty version of the respective object. This can be used when you only need to update a
39-
a subset of the fields of an object as oppose to updating every field of an object.
40-
- note: Using an empty object and updating a subset of the fields reduces the amount of data sent between
39+
a subset of the fields of an object as oppose to updating every field of an object. Using an
40+
empty object and updating a subset of the fields reduces the amount of data sent between
4141
client and server when using `save` and `saveAll` to update objects.
4242
*/
4343
var emptyObject: Self {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ struct Installation: ParseInstallation {
3939
/*:
4040
It's recommended the developer adds the emptyObject computed property or similar.
4141
Gets an empty version of the respective object. This can be used when you only need to update a
42-
a subset of the fields of an object as oppose to updating every field of an object.
43-
- note: Using an empty object and updating a subset of the fields reduces the amount of data sent between
42+
a subset of the fields of an object as oppose to updating every field of an object. Using an
43+
empty object and updating a subset of the fields reduces the amount of data sent between
4444
client and server when using `save` and `saveAll` to update objects.
4545
*/
4646
var emptyObject: Self {

Scripts/jazzy.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ bundle exec jazzy \
55
--github_url https://github.com/parse-community/Parse-Swift \
66
--root-url http://parseplatform.org/Parse-Swift/api/ \
77
--module-version ${BUILD_VERSION} \
8-
--theme apple \
8+
--theme fullwidth \
99
--skip-undocumented \
1010
--output ./docs/api \
11+
--build-tool-arguments -scheme,'ParseSwift (iOS)',-destination,'name=iPhone 12 Pro Max' \
1112
--module ParseSwift \
12-
--swift-build-tool spm \
13-
--build-tool-arguments -Xswiftc,-swift-version,-Xswiftc,5

Sources/ParseSwift/Objects/ParseObject.swift

+49-5
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,63 @@ import Foundation
1212
Objects that conform to the `ParseObject` protocol have a local representation of data persisted to the Parse cloud.
1313
This is the main protocol that is used to interact with objects in your app.
1414

15-
If you plan to use custom encoding/decoding, be sure to add `objectId`, `createdAt`, `updatedAt`, and
16-
`ACL` to your `ParseObject` `CodingKeys`.
15+
The Swift SDK is designed for your `ParseObject`s to be "value types" (structs).
16+
If you are using value types the the compiler will assist you with conforming to `ParseObject` protocol. If you
17+
are thinking of using reference types, see the warning.
18+
19+
It's recommended the developer adds the emptyObject computed property or similar.
20+
Gets an empty version of the respective object. This can be used when you only need to update a
21+
a subset of the fields of an object as oppose to updating every field of an object. Using an empty object and updating
22+
a subset of the fields reduces the amount of data sent between client and server when using `save` and `saveAll`
23+
to update objects. You should add the following properties in your `ParseObject`'s:
24+
25+
var emptyObject: Self {
26+
var object = Self()
27+
object.objectId = objectId
28+
object.createdAt = createdAt
29+
return object
30+
}
31+
32+
When designing applications for SwiftUI, it is recommended to make all `ParseObject`'s conform to
33+
`Identifiable`. This can be accomplised by doing the following:
1734

18-
- note: It is recommended to make your`ParseObject`s "value types" (structs).
19-
If you are using value types there isn't much else you need to do but to conform to ParseObject. If you are thinking of
20-
using reference types, see the warning.
35+
struct GameScore: ParseObject, Identifiable {
36+
37+
// Add this computed property to conform to `Identifiable` for iOS13+
38+
var id: String {
39+
guard let objectId = self.objectId else {
40+
return UUID().uuidString
41+
}
42+
return objectId
43+
}
44+
45+
// These are required for any Object.
46+
var objectId: String?
47+
var createdAt: Date?
48+
var updatedAt: Date?
49+
var ACL: ParseACL?
50+
51+
// Your own properties.
52+
var score: Int = 0
53+
var location: ParseGeoPoint?
54+
var name: String?
55+
var myFiles: [ParseFile]?
56+
}
57+
58+
- important: It is recommended that all added properties be optional properties so they can eventually be used as
59+
Parse `Pointer`'s. If a developer really wants to have a required key, they should require it on the server-side or
60+
create methods to check the respective properties on the client-side before saving objects. See
61+
[here](https://github.com/parse-community/Parse-Swift/issues/157#issuecomment-858671025)
62+
for more information.
2163
- warning: If you plan to use "reference types" (classes), you are using at your risk as this SDK is not designed
2264
for reference types and may have unexpected behavior when it comes to threading. You will also need to implement
2365
your own `==` method to conform to `Equatable` along with with the `hash` method to conform to `Hashable`.
2466
It is important to note that for unsaved `ParseObject`'s, you won't be able to rely on `objectId` for
2567
`Equatable` and `Hashable` as your unsaved objects won't have this value yet and is nil. A possible way to
2668
address this is by creating a `UUID` for your objects locally and relying on that for `Equatable` and `Hashable`,
2769
otherwise it's possible you will get "circular dependency errors" depending on your implementation.
70+
- note: If you plan to use custom encoding/decoding, be sure to add `objectId`, `createdAt`, `updatedAt`, and
71+
`ACL` to your `ParseObject` `CodingKeys`.
2872
*/
2973
public protocol ParseObject: Objectable,
3074
Fetchable,

Sources/ParseSwift/ParseConstants.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010

1111
enum ParseConstants {
1212
static let sdk = "swift"
13-
static let version = "1.10.3"
13+
static let version = "1.10.4"
1414
static let fileManagementDirectory = "parse/"
1515
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
1616
static let fileManagementLibraryDirectory = "Library/"

0 commit comments

Comments
 (0)