(NSFetchedResultsController): couldn’t read cache file to update store info timestamps

This error should not be ignored because it can cause app crash. It is related to an iOS 10 bug of file descriptor leaks. There are reports on openradar and Apple Bug Reporter. What happen: if you load a view controller using NSFetchedResultsController with a non-nil cacheName, every time you save the managed object context … Read more

How to sync records between Core Data and CloudKit efficiently

As of iOS 13, there are new API’s that simplify this synchronization for developers. I would recommend you to watch the WWDC19 session about the new synchronization between CoreData and CloudKit. Please note that these new API’s only work for iOS 13+. Video: https://developer.apple.com/videos/play/wwdc2019/202/ In short, you need to start using NSPersistentCloudKitContainer instead of NSPersistentContainer. … Read more

Resume NSUrlSession on iOS10

This problem arose from currentRequest and originalRequest NSKeyArchived encoded with an unusual root of “NSKeyedArchiveRootObjectKey” instead of NSKeyedArchiveRootObjectKey constant which is “root” literally and some other misbehaves in encoding process of NSURL(Mutable)Request. I detected that in beta 1 and filed a bug (no. 27144153 in case you want duplicate). Even I sent an email to … Read more

Deleting all data in a Core Data entity in Swift 3

You’re thinking of NSBatchDeleteRequest, which was added in iOS 9. Create one like this: let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: “Employee”) let request = NSBatchDeleteRequest(fetchRequest: fetch) You can also add a predicate if you only wanted to delete instances that match the predicate. To run the request: let result = try managedObjectContext.executeRequest(request) Note that batch requests don’t … Read more