$30 off During Our Annual Pro Sale. View Details »

Core Data Fundamentals

Ajith R Nayak
September 22, 2021

Core Data Fundamentals

I gave a talk on Core Data in a Nutshell and its concurrency rules.

Ajith R Nayak

September 22, 2021
Tweet

More Decks by Ajith R Nayak

Other Decks in Technology

Transcript

  1. NSManagedObjectContext • Like a scratchpad • fetch, change, add and

    delete • Create more than one contexts • Updates persistent store
  2. perform(_:) • asynchronous method • gets wrapped in a autorelease

    pool. performAndWait(_:) • synchronous method • will block the calling thread • does not wrap the block in an 
 autorelease pool.
  3. Summary • A managed object context is tied to a

    serial queue. • Create only two contexts for simplicity. • Concurrency types are two but contexts can be many. • Context executes on a “private” queue. • Performance heavy operations should be performed on the background queue. • Don’t pass NSManagedObject instances between queues. • To avoid unnecessary saves, be aware of automatically triggered broadcasts.