Improvements to CoreData in iOS 8/OS X 10.10
After reading a lot of WWDC sets, I feel I have to forget it again if I don't take any notes. So let's start with CoreData, which has the biggest relationship with me.
Since CoreData was first logged on to OS x 10.4 Tiger, after so many versions of development, all aspects have been quite well developed. Therefore, in this iOS 8/OS X 10.10, coreData features do not change much. There are only a few items, but they all focus on performance and experience and are very useful.
These are:
Batch UpdatesThis may be the first reason why CoreData is not needed: What? I cannot write a simple SQL statement to update or delete a field of all my entries. is such a database? The fact is that CoreData is not a database, but after so many years of development, this Batch Updates finally makes it more database-friendly.
By adding NSBatchUpdateReuqest and NSBatchUpdateResult to update data in batches, you can quickly modify the entire database by updating the database using SQL-like languages, instead of updating each Object as before, it is slow and consumes memory. It returns success or failure, the number of changed rows, and the ID array to be changed, just like querying the database.
Of course, this Batch Updates will have a side effect-that is, the updated Context does not have a corresponding response, so you need to manually refresh the Context to avoid interface and data inconsistency. Other verifications limited to NSManagedObject also fail, so -- just like operating a traditional database, be careful to use the Batch Updates of CoreData.
Asynchronous FetchingThis is a good improvement in experience. Finally, there is a built-in "Asynchronous acquisition" method with excellent design. What's better is that it can also work with NSProgress, therefore, "Asynchronous" + "Progress Update" can be easily supported. This is mainly done by the newly added NSAsynchronousFetchResult class. This is a very typical thing for immediate return + Result callback. You need to perform this operation in the Private or Main Context, other functions are very simple. Asynchronous Fetching is required when many entries need to be loaded at a time.
Others
The Incremental store section is not easy to understand. You need to read it again. In addition, in terms of concurrency, CoreData not only supports javasmblock on NSManagedContext, but also supports NSPersistentStoreCoordinator. I have no idea about this. After all, I have not used multiple StoreCoordinator.
In addition, iOS, like OS X, also supports such debug for Concurrecy: com. apple. coreData. concurrencyDebug 1 is about Swift's support for CoreData, which is basically the same as Objective-C. The main reason is that NSManagedObject needs to use @ NSManaged to modify the variable, in addition, the namespace of the class also needs to be written in the Model. According to the official demonstration example, CoreData programs written in Swift in the same database have higher performance than Objective-C... I can't wait to use Swift to write my iOS App.
Link: http://www.cocoachina.com/applenews/devnews/2014/0724/9235.html