Re: CoreData models as structures
Re: CoreData models as structures
- Subject: Re: CoreData models as structures
- From: Quincey Morris <email@hidden>
- Date: Sat, 6 Nov 2010 13:11:17 -0700
On Nov 6, 2010, at 11:41, Ayers, Joseph wrote:
> The fundamental problem seems to be nested to-many relationships. The sample code twomanycontroller seems to do what I want, but it's pre-core data and the data model won't open. One wonders how a coredata version of that would work.
Again, it depends on what you're trying to do. Your tape list has tapes, and your tapes have video clips, and your video clips have tables (and so on). So, you have a tree structure of objects. Are you trying to walk the whole tree? If so, you can nest Objective-C 'for' constructs:
for (tapes* tape in tapeList.tapes)
for (VideoClip* videoClip in tape.VideoClip)
for (Table* table in videoClip.Table)
... do something with a table...
If you only want a specific object (or some objects), you can use a Core Data fetch to find it (or them). That'll give you a single result (or an array of results to iterate through).
If you're talking about showing tables in the UI, then probably array controllers enter the picture. For example, if you want one table to show the tapes and an adjacent table to show the video clips in the selected tape, you'd bind the second table's array controller to the first array controller's "selection" property. (Conceptually, you'd be solving your original problem by referencing tape.selection.VideoClip, which is well-defined, instead of tape.VideoClip, which is not.)
Note that in your data model you have several inconsistencies in your use of plurals, not to mention capitalization. That usually indicates you haven't clearly separated in your mind what's an object from what's a set of objects (i.e. a relationship). I think that's the problem you're really fighting here, not a coding issue.
_______________________________________________
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