@@ -82,6 +82,30 @@ public protocol ParseObject: ParseTypeable,
8282 */
8383 init ( )
8484
85+ /**
86+ Creates a `ParseObject` with a specified `objectId`. Can be used to create references or associations
87+ between `ParseObject`'s.
88+ - warning: It is required that all added properties be optional properties so they can eventually be used as
89+ Parse `Pointer`'s. If a developer really wants to have a required key, they should require it on the server-side or
90+ create methods to check the respective properties on the client-side before saving objects. See
91+ [here](https://github.com/parse-community/Parse-Swift/pull/315#issuecomment-1014701003)
92+ for more information.
93+ */
94+ init ( objectId: String )
95+
96+ /**
97+ Determines if two objects have the same objectId.
98+ - parameter as: Object to compare.
99+ - returns: Returns a **true** if the other object has the same `objectId` or **false** if unsuccessful.
100+ */
101+ func hasSameObjectId< T: ParseObject > ( as other: T ) -> Bool
102+
103+ /**
104+ Converts this `ParseObject` to a Parse Pointer.
105+ - returns: The pointer version of the `ParseObject`, Pointer<Self>.
106+ */
107+ func toPointer( ) throws -> Pointer < Self >
108+
85109 /**
86110 Determines if a `KeyPath` of the current `ParseObject` should be restored
87111 by comparing it to another `ParseObject`.
@@ -148,29 +172,11 @@ public protocol ParseObject: ParseTypeable,
148172// MARK: Default Implementations
149173public extension ParseObject {
150174
151- /**
152- Creates a `ParseObject` with a specified `objectId`. Can be used to create references or associations
153- between `ParseObject`'s.
154- - warning: It is required that all added properties be optional properties so they can eventually be used as
155- Parse `Pointer`'s. If a developer really wants to have a required key, they should require it on the server-side or
156- create methods to check the respective properties on the client-side before saving objects. See
157- [here](https://github.com/parse-community/Parse-Swift/pull/315#issuecomment-1014701003)
158- for more information.
159- */
160- init ( objectId: String ) {
161- self . init ( )
162- self . objectId = objectId
163- }
164-
165- func hash( into hasher: inout Hasher ) {
166- hasher. combine ( self . id)
167- }
168-
169175 /**
170176 A computed property that is a unique identifier and makes it easy to use `ParseObject`'s
171177 as models in MVVM and SwiftUI.
172- - note: `id` allows `ParseObject`'s to be used even when they are not saved and do not have an `objectId`.
173- - important: `id` will have the same value as `objectId` when a `ParseObject` is saved .
178+ - note: `id` allows `ParseObject`'s to be used even if they have not been saved and/or missing an `objectId`.
179+ - important: `id` will have the same value as `objectId` when a `ParseObject` contains an `objectId` .
174180 */
175181 var id : String {
176182 objectId ?? UUID ( ) . uuidString
@@ -188,21 +194,17 @@ public extension ParseObject {
188194 return object
189195 }
190196
191- /**
192- Determines if two objects have the same objectId.
193- - parameter as: Object to compare.
194- - returns: Returns a **true** if the other object has the same `objectId` or **false** if unsuccessful.
195- */
197+ init ( objectId : String ) {
198+ self . init ( )
199+ self . objectId = objectId
200+ }
201+
196202 func hasSameObjectId< T: ParseObject > ( as other: T ) -> Bool {
197- return other. className == className && other. objectId == objectId && objectId != nil
203+ other. className == className && other. objectId == objectId && objectId != nil
198204 }
199205
200- /**
201- Converts this `ParseObject` to a Parse Pointer.
202- - returns: The pointer version of the `ParseObject`, Pointer<Self>.
203- */
204206 func toPointer( ) throws -> Pointer < Self > {
205- return try Pointer ( self )
207+ try Pointer ( self )
206208 }
207209
208210 func shouldRestoreKey< W> ( _ keyPath: KeyPath < Self , W ? > ,
@@ -240,6 +242,13 @@ extension ParseObject {
240242 }
241243}
242244
245+ // MARK: Hashable
246+ public extension ParseObject {
247+ func hash( into hasher: inout Hasher ) {
248+ hasher. combine ( self . id)
249+ }
250+ }
251+
243252// MARK: Helper Methods
244253public extension ParseObject {
245254 /**
0 commit comments