Please find below how my NSBatchInsertRequest looks like : if let backup = try? JSONSerialization.jsonObject(with: dataFile.read(), options: []) as? [String: Any] {
do {
if let categories = backup["categories"] as? [[String: Any]] {
let _ = try managedContext.execute(NSBatchInsertRequest(entity: Category.entity(), objects: categories))
}
if let storages = backup["storages"] as? [[String: Any]] {
let _ = try managedContext.execute(NSBatchInsertRequest(entity: Storage.entity(), objects: data: storages))
}
} catch {
self.finish(with: RestoreError.parsingBackupFile)
}
}Do I need to iterate over each [[String:Any]] and convert data to the correct type explicitly before preparing the NSBatchInsertRequest ?
Post
Replies
Boosts
Views
Activity
Thank you ! Then I guess I'll go with options 2 replace date with a NSNumber.
I have this same issue of slow simulator but only on my Intel machine, in the M1 ones everything works smoothly.
I had the same issue, what I did to fix the issue, in the Widgets IntentTimelineProvider I had initialised the NSManagedContext in the constructor, just trying to remove this initialisation and putting it in the timeline method did fix the issue for me. I didn't have to separate the live activity in its own target and now both live activity and widgets are on the same target and working.
If you initialise something like CoreData in the constructor of your IntentTimelineProvider in one the widgets you have try to move it out of there maybe it will fix your issue.