Friday, April 26, 2019

[iOS] - Core Data Notes


  1. Core data is a framework to manage you data graph, not a database. It support data being saved as XML, binary, SQLite and Memory.
  2. One app could have multiple data stores, because for some cases, some data need to store in memory, some need to store in SQLite, etc.
  3. Managed object can't be passed crossing thread, but you can do it by using its ManagedObjectID.
  4. MOC(Managed Object Context) - the data change is only propagated from child to parent and not the other round, and not propagated between siblings.
  5. Multiple thread (concurrency) supports - main queue and private queue in background thread, you have to use perform related methods to save the change if it's in a private queue.
  6. Merge types: as the data may be reading and writing in multiple thread, you should choose data merge type for data propagating. Types includes: trump memory, trump object, override, discard.
  7. Memory and performance
    1. Specify the fields only that you desire.
    2. Result limitation.
    3. Decrease fault overhead by using batch faulting and prefetching.
    4. Check and manage you data in memory like using reset method, etc.
      https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CoreData/Performance.html#//apple_ref/doc/uid/TP40001075-CH25-SW1

No comments:

Post a Comment