{"id":362437,"date":"2024-05-21T01:35:08","date_gmt":"2024-05-21T01:35:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=362437"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=362437","title":{"rendered":"<span>Swift Utilities \u2014 \u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u043e SwiftData \u0432 Background<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0430 \u0433\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c iOS, \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0448\u0442\u0443\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f. \u042f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439, \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0435\u0451 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043b\u044f \u0432\u0430\u0441.<\/p>\n<p>SwiftData \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 View: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@Query<\/code> \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443, \u0438 \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c &#8216;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#8217;. \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u043e SwiftData \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u0430\u0441\u0430\u0435\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435.<\/p>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0435\u0437 <code>@Query:<\/code><\/p>\n<pre><code class=\"swift\">func getMyModels() -> [MyModel] {     let context = ModelContext(modelContainer)     let result = try context.fetch(FetchDescriptor&lt;MyModel>())     return result }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0435\u043d. \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443, \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0448, \u0432 \u0445\u0443\u0434\u0448\u0435\u043c, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f, \u043d\u043e \u0441 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c.<\/p>\n<p>\u0421\u0430\u043c\u044b\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043c\u044c\u044e\u0442\u0435\u043a\u0441 (NSLock, UnfairLock, DispatchSemaphore \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435)<\/p>\n<pre><code class=\"swift\">func getMyModels() -> [MyModel] {     \/\/ \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430 \u043d\u0435 \u0432\u0430\u0436\u043d\u0430     mutex {       let context = ModelContext(modelContainer)       let result = try context.fetch(FetchDescriptor&lt;MyModel>())       return result     } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u043f\u0435\u0440\u0435\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u043a\u0440\u0430\u0448\u0430\u043c\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435  \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u043b\u0430\u0441\u044c.<\/p>\n<p>\u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 <code>DefaultSerialModelExecutor<\/code>. \u041e\u043d \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0430\u043a\u0442\u043e\u0440 <code>BackgroundSerialPersistenceActor&lt;T: PersistentModel><\/code><\/p>\n<pre><code class=\"swift\">import Foundation import SwiftData  \/\/\/ ```swift \/\/\/  \/\/ It is important that this actor works as a mutex,  \/\/\/  \/\/ so you must have one instance of the Actor for one container  \/\/   \/\/ for it to work correctly. \/\/\/  let actor = BackgroundSerialPersistenceActor(container: modelContainer) \/\/\/ \/\/\/  Task { \/\/\/      let data: [MyModel] = try? await actor.fetchData() \/\/\/  } \/\/\/  ``` @available(iOS 17, *) public actor BackgroundSerialPersistenceActor: ModelActor {      public let modelContainer: ModelContainer     public let modelExecutor: any ModelExecutor     private var context: ModelContext { modelExecutor.modelContext }      public init(container: ModelContainer) {         self.modelContainer = container         let context = ModelContext(modelContainer)         modelExecutor = DefaultSerialModelExecutor(modelContext: context)     }      public func fetchData&lt;T: PersistentModel>(         predicate: Predicate&lt;T>? = nil,         sortBy: [SortDescriptor&lt;T>] = []     ) throws -> [T] {         let fetchDescriptor = FetchDescriptor&lt;T>(predicate: predicate, sortBy: sortBy)         let list: [T] = try context.fetch(fetchDescriptor)         return list     }      public func fetchCount&lt;T: PersistentModel>(         predicate: Predicate&lt;T>? = nil,         sortBy: [SortDescriptor&lt;T>] = []     ) throws -> Int {         let fetchDescriptor = FetchDescriptor&lt;T>(predicate: predicate, sortBy: sortBy)         let count = try context.fetchCount(fetchDescriptor)         return count     }      public func insert&lt;T: PersistentModel>(data: T) {         let context = data.modelContext ?? context         context.insert(data)     }      public func save() throws {         try context.save()     }      public func remove&lt;T: PersistentModel>(predicate: Predicate&lt;T>? = nil) throws {         try context.delete(model: T.self, where: predicate)     }      public func saveAndInsertIfNeeded&lt;T: PersistentModel>(         data: T,          predicate: Predicate&lt;T>     ) throws {         let descriptor = FetchDescriptor&lt;T>(predicate: predicate)         let context = data.modelContext ?? context         let savedCount = try context.fetchCount(descriptor)          if savedCount == 0 {             context.insert(data)         }         try context.save()     } }<\/code><\/pre>\n<p>\u0410\u043a\u0442\u043e\u0440 <code>BackgroundSerialPersistenceActor&lt;T: PersistentModel><\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439  \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u0410\u043a\u0442\u043e\u0440 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438 (<code>ModelContainer<\/code>) \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 (<code>ModelExecutor<\/code>), \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"swift\">let actor = BackgroundSerialPersistenceActor(container: modelContainer)  Task {     let data: [MyModel] = try? await actor.fetchData() }<\/code><\/pre>\n<h3>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u043a\u0442\u043e\u0440\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438. <\/p>\n<p>\u0412\u0430\u0436\u043d\u043e, \u044d\u0442\u043e\u0442 \u0430\u043a\u0442\u043e\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043c\u044c\u044e\u0442\u0435\u043a\u0441, \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0410\u043a\u0442\u043e\u0440\u0430  \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. <\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p><code>BackgroundSerialPersistenceActor<\/code> \u043e\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c, \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 fetch, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 (PersistentModel) \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043f\u043e\u0442\u043e\u043a\u0438, \u043e\u043d\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0443 \u043e\u0434\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043a\u0440\u0430\u0448\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435 fetch \u043c\u0430\u043f\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443.<\/p>\n<p>SwiftData \u2014 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043d\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c<\/p>\n<h4>\u0415\u0449\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 Swift Utilities:<\/h4>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/774884\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014 \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0426\u0432\u0435\u0442\u0430\u043c\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/774888\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014 \u0423\u043f\u0440\u043e\u0449\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 UserDefaults<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/774890\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014\u00a0\u041f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/774894\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014 Equatable \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 Enum<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/778154\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014 \u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f SwiftUI \u0432 UIKit<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/779450\/\"> https:\/\/habr.com\/ru\/articles\/779450\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0430 \u0433\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c iOS, \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0448\u0442\u0443\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f. \u042f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439, \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0435\u0451 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043b\u044f \u0432\u0430\u0441.<\/p>\n<p>SwiftData \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 View: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@Query<\/code> \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443, \u0438 \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c &#8216;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#8217;. \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u043e SwiftData \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u0430\u0441\u0430\u0435\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435.<\/p>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0435\u0437 <code>@Query:<\/code><\/p>\n<pre><code class=\"swift\">func getMyModels() -> [MyModel] {     let context = ModelContext(modelContainer)     let result = try context.fetch(FetchDescriptor&lt;MyModel>())     return result }<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0435\u043d. \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443, \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0448, \u0432 \u0445\u0443\u0434\u0448\u0435\u043c, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f, \u043d\u043e \u0441 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c.<\/p>\n<p>\u0421\u0430\u043c\u044b\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043c\u044c\u044e\u0442\u0435\u043a\u0441 (NSLock, UnfairLock, DispatchSemaphore \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435)<\/p>\n<pre><code class=\"swift\">func getMyModels() -> [MyModel] {     \/\/ \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430 \u043d\u0435 \u0432\u0430\u0436\u043d\u0430     mutex {       let context = ModelContext(modelContainer)       let result = try context.fetch(FetchDescriptor&lt;MyModel>())       return result     } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u043f\u0435\u0440\u0435\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u043a\u0440\u0430\u0448\u0430\u043c\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435  \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u043b\u0430\u0441\u044c.<\/p>\n<p>\u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 <code>DefaultSerialModelExecutor<\/code>. \u041e\u043d \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0430\u043a\u0442\u043e\u0440 <code>BackgroundSerialPersistenceActor&lt;T: PersistentModel><\/code><\/p>\n<pre><code class=\"swift\">import Foundation import SwiftData  \/\/\/ ```swift \/\/\/  \/\/ It is important that this actor works as a mutex,  \/\/\/  \/\/ so you must have one instance of the Actor for one container  \/\/   \/\/ for it to work correctly. \/\/\/  let actor = BackgroundSerialPersistenceActor(container: modelContainer) \/\/\/ \/\/\/  Task { \/\/\/      let data: [MyModel] = try? await actor.fetchData() \/\/\/  } \/\/\/  ``` @available(iOS 17, *) public actor BackgroundSerialPersistenceActor: ModelActor {      public let modelContainer: ModelContainer     public let modelExecutor: any ModelExecutor     private var context: ModelContext { modelExecutor.modelContext }      public init(container: ModelContainer) {         self.modelContainer = container         let context = ModelContext(modelContainer)         modelExecutor = DefaultSerialModelExecutor(modelContext: context)     }      public func fetchData&lt;T: PersistentModel>(         predicate: Predicate&lt;T>? = nil,         sortBy: [SortDescriptor&lt;T>] = []     ) throws -> [T] {         let fetchDescriptor = FetchDescriptor&lt;T>(predicate: predicate, sortBy: sortBy)         let list: [T] = try context.fetch(fetchDescriptor)         return list     }      public func fetchCount&lt;T: PersistentModel>(         predicate: Predicate&lt;T>? = nil,         sortBy: [SortDescriptor&lt;T>] = []     ) throws -> Int {         let fetchDescriptor = FetchDescriptor&lt;T>(predicate: predicate, sortBy: sortBy)         let count = try context.fetchCount(fetchDescriptor)         return count     }      public func insert&lt;T: PersistentModel>(data: T) {         let context = data.modelContext ?? context         context.insert(data)     }      public func save() throws {         try context.save()     }      public func remove&lt;T: PersistentModel>(predicate: Predicate&lt;T>? = nil) throws {         try context.delete(model: T.self, where: predicate)     }      public func saveAndInsertIfNeeded&lt;T: PersistentModel>(         data: T,          predicate: Predicate&lt;T>     ) throws {         let descriptor = FetchDescriptor&lt;T>(predicate: predicate)         let context = data.modelContext ?? context         let savedCount = try context.fetchCount(descriptor)          if savedCount == 0 {             context.insert(data)         }         try context.save()     } }<\/code><\/pre>\n<p>\u0410\u043a\u0442\u043e\u0440 <code>BackgroundSerialPersistenceActor&lt;T: PersistentModel><\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439  \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u0410\u043a\u0442\u043e\u0440 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438 (<code>ModelContainer<\/code>) \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 (<code>ModelExecutor<\/code>), \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"swift\">let actor = BackgroundSerialPersistenceActor(container: modelContainer)  Task {     let data: [MyModel] = try? await actor.fetchData() }<\/code><\/pre>\n<h3>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u043a\u0442\u043e\u0440\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438. <\/p>\n<p>\u0412\u0430\u0436\u043d\u043e, \u044d\u0442\u043e\u0442 \u0430\u043a\u0442\u043e\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043c\u044c\u044e\u0442\u0435\u043a\u0441, \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0410\u043a\u0442\u043e\u0440\u0430  \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. <\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p><code>BackgroundSerialPersistenceActor<\/code> \u043e\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c, \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 fetch, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 (PersistentModel) \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043f\u043e\u0442\u043e\u043a\u0438, \u043e\u043d\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0443 \u043e\u0434\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043a\u0440\u0430\u0448\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435 fetch \u043c\u0430\u043f\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443.<\/p>\n<p>SwiftData \u2014 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043d\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c<\/p>\n<h4>\u0415\u0449\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 Swift Utilities:<\/h4>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/774884\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014 \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0426\u0432\u0435\u0442\u0430\u043c\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/774888\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014 \u0423\u043f\u0440\u043e\u0449\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 UserDefaults<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/774890\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014\u00a0\u041f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/774894\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014 Equatable \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 Enum<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/778154\/\" rel=\"noopener noreferrer nofollow\">Swift Utilities \u2014 \u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f SwiftUI \u0432 UIKit<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/779450\/\"> https:\/\/habr.com\/ru\/articles\/779450\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-362437","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/362437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=362437"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/362437\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=362437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=362437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=362437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}