@@ -22,28 +22,6 @@ public struct ParseFile: Fileable, Savable, Deletable, Hashable, Identifiable {
2222 && data == nil
2323 }
2424
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-
4725 /**
4826 The name of the file.
4927 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 {
159137 self . options = options
160138 }
161139
162- public func hash( into hasher: inout Hasher ) {
163- hasher. combine ( self . id)
164- }
165-
166140 public func isSaved( ) async throws -> Bool {
167141 isSaved
168142 }
@@ -174,6 +148,30 @@ public struct ParseFile: Fileable, Savable, Deletable, Hashable, Identifiable {
174148 }
175149}
176150
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+
177175// MARK: Helper Methods (internal)
178176extension ParseFile {
179177 func combineName( with url: URL ) -> String {
0 commit comments