Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Concurrency with Core Data

Ff90de2297b7e3136fa3c4a971b0b1c5?s=47 Josh Johnson
December 04, 2011

Concurrency with Core Data

Threading is a complex problem in applications. Adding Core Data to the mix doesn't make it easier. However, if you follow some rules you can perform Core Data operations on Background queues without too much trouble.

Ff90de2297b7e3136fa3c4a971b0b1c5?s=128

Josh Johnson

December 04, 2011
Tweet

Transcript

  1. Background Saving with Core Data Josh Johnson josh@twotoasters.com twitter.com/jnjosh Sunday,

    December 4, 11
  2. Concurrency with Core Data Josh Johnson josh@twotoasters.com twitter.com/jnjosh Sunday, December

    4, 11
  3. “Why support concurrency?” Sunday, December 4, 11

  4. http://skitch.com/okidokie/nm31y/beach-ball-mac-osx Sunday, December 4, 11

  5. Wait... Isn’t this too hard? Sunday, December 4, 11

  6. Wait... Isn’t this too hard? http://www.wallchan.com/sandbox/57897/ Sunday, December 4, 11

  7. http://kelvinslush.com/blog/the-rules Sunday, December 4, 11

  8. Thread Confinement Sunday, December 4, 11

  9. NSManagedObjectContext NSManagedObject Rule 1. & Sunday, December 4, 11

  10. NSManagedObjectContext NSManagedObject Rule 1. & Not Thread-safe Sunday, December 4,

    11
  11. NSManagedObjectId Rule 2. Sunday, December 4, 11

  12. NSManagedObjectId Rule 2. Is Thread-safe Sunday, December 4, 11

  13. NSManagedObjectId Rule 2. Is Thread-safe [otherMoc objectWithID:objectID] Sunday, December 4,

    11
  14. Merge Changes from Notifications Rule 3. Sunday, December 4, 11

  15. Merge Changes from Notifications Rule 3. NSManagedObjectContextDidSaveNotification Sunday, December 4,

    11
  16. Merge Changes from Notifications Rule 3. NSManagedObjectContextDidSaveNotification [moc mergeChangesFromContextDidSaveNotification:note]; Sunday,

    December 4, 11
  17. No Thread Confinement? Sunday, December 4, 11

  18. http://63angel.blogspot.com/2011/07/danger-will-robinson-obsessions.html Sunday, December 4, 11

  19. http://pennystockgurus.blogspot.com/2010_07_01_archive.html Sunday, December 4, 11

  20. “Siri, make my app better” Sunday, December 4, 11

  21. http://skitch.com/okidokie/nm31y/beach-ball-mac-osx Demo NSOperation Sunday, December 4, 11

  22. Wait... Isn’t this too hard? http://www.wallchan.com/sandbox/57897/ Sunday, December 4, 11

  23. GCD & Blocks Sunday, December 4, 11

  24. Grand Central Dispatch & Blocks Concurrent And Asynchronous Programming With

    GCD Nathan Eror Saturday @ 2:45pm Sunday, December 4, 11
  25. “The irresponsibly quick review” Grand Central Dispatch & Blocks Sunday,

    December 4, 11
  26. Blocks http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/00_Introduction.html Sunday, December 4, 11

  27. GCD dispatch_async(dispatch_get_main_queue(), ^{ [self doSomethingImportantOnMainQueue]; }); dispatch_async(myQueue, ^{ [self doSomethingImportant];

    }); Sunday, December 4, 11
  28. Grand Central Dispatch & Blocks Concurrent And Asynchronous Programming With

    GCD Nathan Eror Saturday @ 2:45pm Sunday, December 4, 11
  29. http://skitch.com/okidokie/nm31y/beach-ball-mac-osx Demo GCD & Blocks Sunday, December 4, 11

  30. Sunday, December 4, 11

  31. Core Data Concurrency in iOS 5 Sunday, December 4, 11

  32. Core Data Concurrency in iOS 5 • Concurrency Types Sunday,

    December 4, 11
  33. Core Data Concurrency in iOS 5 • Concurrency Types •

    NSConfinementConcurrencyType • NSMainQueueConcurrencyType • NSPrivateQueueConcurrencyType Sunday, December 4, 11
  34. Core Data Concurrency in iOS 5 • Concurrency Types •

    NSConfinementConcurrencyType • NSMainQueueConcurrencyType • NSPrivateQueueConcurrencyType • Parent / Child Contexts Sunday, December 4, 11
  35. http://skitch.com/okidokie/nm31y/beach-ball-mac-osx Demo Parent / Child Contexts Sunday, December 4, 11

  36. Resources MAGICALRECORD https://github.com/magicalpanda/MagicalRecord  http://developer.apple.com http://cimgf.com Sunday, December 4, 11

  37. Questions? Sunday, December 4, 11

  38. Thank You! Josh Johnson josh@twotoasters.com twitter.com/jnjosh Sunday, December 4, 11