Hi, I have a shared Core Data Container between my app and widget. Both have the same app group enabled. I am using data in my widget that accesses data from Core Data and one single image in FileManager.
In UIApplication.willResignActiveNotification I reload the timeline of my widget and if I make changes to the "one" single image in my FileManager it is immediately reflected in the updated Widget. But I cant figure out how to fetch updated data from my timeline in the widget from Core Data. I can initially load the data from CD using:
But how do I update "items" in
In UIApplication.willResignActiveNotification I reload the timeline of my widget and if I make changes to the "one" single image in my FileManager it is immediately reflected in the updated Widget. But I cant figure out how to fetch updated data from my timeline in the widget from Core Data. I can initially load the data from CD using:
Code Block struct Provider: TimelineProvider { var managedObjectContext : NSManagedObjectContext var items: [Item] = [] init(context : NSManagedObjectContext) { self.managedObjectContext = context let fetchRequest = NSFetchRequest<Item>(entityName: "Item") fetchRequest.sortDescriptors = [NSSortDescriptor(keyPath: \Item.checked, ascending: true), NSSortDescriptor(keyPath: \Item.timestamp, ascending: false)] do { items = try managedObjectContext.fetch(fetchRequest) if items.count == 0 { } } catch let error as NSError { print("Could not fetch: \(error)") } backgroundImageURL = getDocumentsDirectory().appendingPathComponent("background.png") } ... }
But how do I update "items" in
Code Block getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ())