CoreData, and design of document model
CoreData, and design of document model
- Subject: CoreData, and design of document model
- From: David Mirabito <email@hidden>
- Date: Fri, 27 Jan 2012 09:07:52 +0000
Hi,
I have the beginnings of a Document-based App, with CoreData. I don't
expect to get the model 100% perfect from day-1 but neither do I want
to begin with fundamentally incorrect approach.
Let's say my model looks something like this:
System
-> various metadata properties (name, comments, date, ...)
-> Configuration (to one)
-> Manager (to one)
-> Items (to many)
and Item will be abstract so the to-many actually will contain
instances of ItemA, ItemB, ...
So each document represents one System which has one Configuration
object. (is separated into own object as eventyally there will be a
library of these a user can just drop in to their system, and then
tweak) and a bunch of 'Items'
So the root of my document is essentially a singleton System object.
Is there anything particularly broken with this so far? Some searching
seems to indicate that CD and 'root' objects might not be ideal ...
Moving on, how would I enforce this? Right now am working with the
notion that when the document is created I add one System
managedObject if one doesnt exist, and then never add another in the
document's lifetime. Right now in MyDocument's -didLoadNib whilst
experimenting but maybe later I'll find a better delegate method for
that.
Is this a sane starting point, or do I have some poor preconception?
Thanks,
DavidM
PS: I also considered noting that 1 document == 1 system, so the top
level object could be moot. But if I hoist everything up one level, I
still need Configuration, Manager and the metadata to be 'singletons'
so the issue still exists.
Also this way I can pass everything around as a single (System*)
managed object rather than the MOC.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden