@@ -22,28 +22,6 @@ public struct ParseFile: Fileable, Savable, Deletable, Hashable, Identifiable {
22
22
&& data == nil
23
23
}
24
24
25
- /**
26
- A computed property that is a unique identifier and makes it easy to use `ParseFile`'s
27
- as models in MVVM and SwiftUI.
28
- - note: `id` allows `ParseFile`'s to be used even when they are not saved.
29
- - important: `id` will have the same value as `name` when a `ParseFile` is saved.
30
- */
31
- public var id : String {
32
- guard isSaved else {
33
- guard let cloudURL = cloudURL else {
34
- guard let localURL = localURL else {
35
- guard let data = data else {
36
- return name
37
- }
38
- return " \( name) _ \( data) "
39
- }
40
- return combineName ( with: localURL)
41
- }
42
- return combineName ( with: cloudURL)
43
- }
44
- return name
45
- }
46
-
47
25
/**
48
26
The name of the file.
49
27
Before the file is saved, this is the filename given by the user.
@@ -159,10 +137,6 @@ public struct ParseFile: Fileable, Savable, Deletable, Hashable, Identifiable {
159
137
self . options = options
160
138
}
161
139
162
- public func hash( into hasher: inout Hasher ) {
163
- hasher. combine ( self . id)
164
- }
165
-
166
140
public func isSaved( ) async throws -> Bool {
167
141
isSaved
168
142
}
@@ -174,6 +148,30 @@ public struct ParseFile: Fileable, Savable, Deletable, Hashable, Identifiable {
174
148
}
175
149
}
176
150
151
+ // MARK: Identifiable
152
+ extension ParseFile {
153
+ /**
154
+ A computed property that ensures `ParseFile`'s can be uniquely identified across instances.
155
+ - note: `id` allows `ParseFile`'s to be uniquely identified even if they have not been saved.
156
+ - important: `id` will have the same value as `objectId` when a `ParseObject` contains an `objectId`.
157
+ */
158
+ public var id : String {
159
+ guard isSaved else {
160
+ guard let cloudURL = cloudURL else {
161
+ guard let localURL = localURL else {
162
+ guard let data = data else {
163
+ return name
164
+ }
165
+ return " \( name) _ \( data) "
166
+ }
167
+ return combineName ( with: localURL)
168
+ }
169
+ return combineName ( with: cloudURL)
170
+ }
171
+ return name
172
+ }
173
+ }
174
+
177
175
// MARK: Helper Methods (internal)
178
176
extension ParseFile {
179
177
func combineName( with url: URL ) -> String {
0 commit comments