Skip navigation.
 
mlRe: CoreData Best Practices
FROM : John Timmer
DATE : Fri Apr 29 23:28:12 2005

Sorry, didn't quite finish up my thought - got distracted by a phone call.

If you need to hold a more complex object (like a dictionary), model it as a
Core Data object, but include a field for a unique identifier (either string
or NSNumber).  Store that unique identifier in the array, and use it to
retrieve the appropriate "author" entry.

The alternative to this would be to have a location field in the author
object, so that you could use it to sort the set.

Neither of these are great solutions, but both work pretty well.

JT

> If you decide you absolutely need an array of strings, there's a way to do
> it:
>
> Subclass NSManagedObject and add an array ivar
> Make array retrieve/add/delete methods
> Have keyed value that's a string or data
>
> When the array changes, have it save its string representation or coded data
> to the keyed value.  If the array is requested when its ivar is nil, use
> simply re-create it from the keyed value.
>
> There's going to be a problem with large arrays, so this might be painfully
> slow with the human genome publication, but it's fine for most instances.
>

_______________________________________________
This mind intentionally left blank

Related mailsAuthorDate
mlCoreData Best Practices James Clause Apr 29, 16:49
mlRe: CoreData Best Practices John Brownlow Apr 29, 17:36
mlRe: CoreData Best Practices Scott Stevenson Apr 29, 19:07
mlRe: CoreData Best Practices John Timmer Apr 29, 22:34
mlRe: CoreData Best Practices John Timmer Apr 29, 23:28
mlRe: CoreData Best Practices Bill Bumgarner Apr 30, 00:00
mlRe: CoreData Best Practices John Timmer Apr 30, 00:29
mlRe: CoreData Best Practices Scott Ellsworth Apr 30, 00:43
mlRe: CoreData Best Practices Chris Hanson Apr 30, 00:56
mlCoreData: Single coordinator, multiple contexts? Paul Mix Apr 30, 01:03
mlRe: CoreData Best Practices John Timmer Apr 30, 01:13
mlRe: CoreData: Single coordinator, multiple contexts? Scott Stevenson Apr 30, 01:15
mlRe: CoreData Best Practices Scott Stevenson Apr 30, 01:18
mlRe: CoreData: Single coordinator, multiple contexts? mmalcolm crawford Apr 30, 01:47
mlRe: CoreData Best Practices Bill Bumgarner Apr 30, 09:49
mlRe: CoreData: Single coordinator, multiple contexts? Paul Mix Apr 30, 16:38
mlRe: CoreData: Single coordinator, multiple contexts? mmalcolm crawford May 1, 00:09