Friday, September 18, 2009

Core Data

Working with Core Data has been an interesting experience. It's safe to say that none of it worked like I thought it should out of the box. Once I completely digested the documentation it was easier to get my head around some of the concepts. Hopefully I'll get an example application up shortly. Finding any examples that used Core Data with NSFetchedResultsController and background fetching proved to be very difficult.

Lessons learned:
1.) Not thread safe -> merging MOC's, and passing object id's is critical
2.) Locking the persistent store when background fetching is a life saver
3.) NSFetchedResultsController isn't perfect and took a lot of massaging
4.) Don't ever pass MOC's and you'll be better off for it with cleaner code and design
5.) Keep a designated read MOC on view controllers for listening, write to new MOC's, then merge changes into the read MOC on the view controller is my preferred methodology

No comments: