Post

Replies

Boosts

Views

Activity

Reply to PersistenceController and CloudKit
struct PersistenceController { static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init() { container = NSPersistentCloudKitContainer(name: "MJ") guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.Jad.MJ")?.appendingPathComponent("MJ.sqlite") else { fatalError("Shared file container could not be created.") } let storeDescription = NSPersistentStoreDescription(url: fileContainer) storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) storeDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) storeDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "YOUR containerIdentifier") container.persistentStoreDescriptions = [storeDescription] container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’21
Reply to Siri Shortcuts with SwiftUI and Core Data
I tried to observe NSPersistentStoreRemoteChange like this: .onReceive(NotificationCenter.default.publisher(for: .NSPersistentStoreRemoteChange)) { notification in DispatchQueue.main.async { let predicate = items.nsPredicate items.nsPredicate = nil items.nsPredicate = NSPredicate(value: true) items.nsPredicate = predicate } } but the operation that I execute in the closure isn't efficient and gives me an issue: Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’21
Reply to Siri Shortcuts with CoreData
import CoreData struct PersistenceController { static let shared = PersistenceController() let container: NSPersistentContainer init() { container = NSPersistentContainer(name: "SiriShort") guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.SiriShortcut2")?.appendingPathComponent("SiriShort.sqlite") else { fatalError("Shared file container could not be created.") } let storeDescription = NSPersistentStoreDescription(url: fileContainer) storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) storeDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) container.persistentStoreDescriptions = [storeDescription] container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’21
Reply to Collapse button NavigationView SideBar SwiftUI
Does your actual code show the collapse button ? Yes Here is a very similar code struct ContentView: View { var body: some View { NavigationView{ List{ NavigationLink { Text("Hello") } label: { Text("Hello") } NavigationLink { Text("World") } label: { Text("World") } } .navigationTitle("Test") } } } What I want to really achieve is the sidebar that is used in the iPad Settings app, if you know how to do that, it would be perfect. Thank You very much
Topic: UI Frameworks SubTopic: UIKit Tags:
Sep ’21
Reply to How to get NSPersistentCloudKitContainer to sync in background
Hello, have you found a solution for this? Thank You
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to PersistenceController and CloudKit
struct PersistenceController { static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init() { container = NSPersistentCloudKitContainer(name: "MJ") guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.Jad.MJ")?.appendingPathComponent("MJ.sqlite") else { fatalError("Shared file container could not be created.") } let storeDescription = NSPersistentStoreDescription(url: fileContainer) storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) storeDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) storeDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "YOUR containerIdentifier") container.persistentStoreDescriptions = [storeDescription] container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Siri Shortcuts with SwiftUI and Core Data
I tried to observe NSPersistentStoreRemoteChange like this: .onReceive(NotificationCenter.default.publisher(for: .NSPersistentStoreRemoteChange)) { notification in DispatchQueue.main.async { let predicate = items.nsPredicate items.nsPredicate = nil items.nsPredicate = NSPredicate(value: true) items.nsPredicate = predicate } } but the operation that I execute in the closure isn't efficient and gives me an issue: Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Siri Shortcuts with CoreData
mistake
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Siri Shortcuts with CoreData
import CoreData struct PersistenceController { static let shared = PersistenceController() let container: NSPersistentContainer init() { container = NSPersistentContainer(name: "SiriShort") guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.SiriShortcut2")?.appendingPathComponent("SiriShort.sqlite") else { fatalError("Shared file container could not be created.") } let storeDescription = NSPersistentStoreDescription(url: fileContainer) storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) storeDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) container.persistentStoreDescriptions = [storeDescription] container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Siri Shortcuts with CoreData
I just solved it, I forgot to add App Groups, however the app isn't refreshing, to see the new data I have to close it and reopen it, any clue on how to fix this issue, I will post my CoreData Stack
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Returning different dates from CoreData objects using NSPredicate
Ok Thank You
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Returning different dates from CoreData objects using NSPredicate
Why do you absolutely want to use predicate ? Because I Want to use it in @FetchRequest
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Collapse button NavigationView SideBar SwiftUI
Does your actual code show the collapse button ? Yes Here is a very similar code struct ContentView: View { var body: some View { NavigationView{ List{ NavigationLink { Text("Hello") } label: { Text("Hello") } NavigationLink { Text("World") } label: { Text("World") } } .navigationTitle("Test") } } } What I want to really achieve is the sidebar that is used in the iPad Settings app, if you know how to do that, it would be perfect. Thank You very much
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Use onChange on FetchedResults/@FetchRequest variable or get notified when the variable changes
???
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Notify when @FetchRequest changes?
Is there another way? Because this .onRecevie(books.publisher) repeats too many times, I want it to execute one time?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21