Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10668914
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
View Options
diff --git a/Shared/PersistenceManager.swift b/Shared/PersistenceManager.swift
index fd69f13..c5ea6ea 100644
--- a/Shared/PersistenceManager.swift
+++ b/Shared/PersistenceManager.swift
@@ -1,47 +1,49 @@
import CoreData
-#if os(macOS)
+#if os(iOS)
+import UIKit
+#elseif os(macOS)
import AppKit
#endif
class PersistenceManager {
let persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "LocalStorageModel")
container.loadPersistentStores(completionHandler: { (_, error) in
if let error = error {
fatalError("Unresolved error loading persistent store: \(error)")
}
})
return container
}()
init() {
let center = NotificationCenter.default
#if os(iOS)
let notification = UIApplication.willResignActiveNotification
#elseif os(macOS)
let notification = NSApplication.willResignActiveNotification
#endif
// We don't need to worry about removing this observer because we're targeting iOS 9+ / macOS 10.11+; the
// system will clean this up the next time it would be posted to.
// See: https://developer.apple.com/documentation/foundation/notificationcenter/1413994-removeobserver
// And: https://developer.apple.com/documentation/foundation/notificationcenter/1407263-removeobserver
// swiftlint:disable:next discarded_notification_center_observer
center.addObserver(forName: notification, object: nil, queue: nil) { [weak self] _ in
guard let self = self else { return }
self.saveContext()
}
}
func saveContext() {
if persistentContainer.viewContext.hasChanges {
do {
try persistentContainer.viewContext.save()
} catch {
print("Error saving context: \(error)")
}
}
}
}
diff --git a/WFACollection+CoreDataProperties.swift b/WFACollection+CoreDataProperties.swift
index 4a578b2..7aceb40 100644
--- a/WFACollection+CoreDataProperties.swift
+++ b/WFACollection+CoreDataProperties.swift
@@ -1,22 +1,22 @@
import Foundation
import CoreData
extension WFACollection {
@nonobjc public class func fetchRequest() -> NSFetchRequest<WFACollection> {
return NSFetchRequest<WFACollection>(entityName: "WFACollection")
}
@NSManaged public var alias: String?
@NSManaged public var blogDescription: String?
@NSManaged public var email: String?
@NSManaged public var isPublic: Bool
@NSManaged public var styleSheet: String?
@NSManaged public var title: String?
@NSManaged public var url: String?
}
-extension WFACollection : Identifiable {
+extension WFACollection: Identifiable {
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, May 15, 11:13 AM (20 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3239683
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment