views:

34

answers:

1

A conceptual question:

I have data stored hierarchically via Core Data SQLite for an iPhone app. I wish both to draw AND to perform calculations based upon properties of each object in the entire hierarchical arrangement of objects. Both drawing and calculating tasks access the same exact properties. Simple enough. However, I anticipate that performing both drawing and calculation on the main thread will cause some problems with UI responsiveness. Using two MOCs to access the same data but on different threads sounds a little silly to me at first pass (traversing the tree twice, once in each thread). Honestly, I'm not convinced multi-threading would help too much.

Would someone enumerate generic options for achieving reasonable app performance in this particular case?

Thanks.

+2  A: 

First, and always, don't make design decisions of this type without actual performance data. You need to profile both the single and multi-threaded approaches. That said, best practices for multi-threading with Core Data dictate one NSManagedObjectContext per-thread, but a single NSPersistentStoreCoordinator. Because row-level caching is done in the persistent store coordinator, it's possible that your multiple-traversals will not incur an unreasonable overhead.

Barry Wark
+1 "don't make design decisions of this type without actual performance data."
TechZen
Barry: can you provide a documentation reference for the row-level caching comment you made?
karl
Well, there's this response from Ben Trumbull, a Core Data dev. that corroborates what I just said. I don't see anything in the official docs that makes it clear.
Barry Wark