On Aug 3, 2010, at 13:37, Ignacio Enriquez wrote:

> User can create files and folders (they don't have to be real folders/files).
> Folders can contain files or other folders
> Files have:
> title,
> summary and
> 8 children
> Each child also has a title and a summary and could have 8 children 
> (optionally)
> This could be as many levels (recursive) as the user desires.
> I am not sure how to express this in CoreData. Could someone give a hand here?
> 
> This is what I've done: http://yfrog.com/j2o1op
> 
> "Child" entity with "title" and "summary" attributes and "children"
> (to-many) relationship pointing to "Child" entity
> "File" entity with "isDirectory" and "name" attributes and "files"
> (to-many)  relationship pointing to "File" entity  and "children"
> (to-many) relationship pointing to "Child" entity.
> 
> Doing that gets me a warning:
> File.children -- to-many relationship does not have an inverse:  this
> is an advanced setting (no object can be in multiple destinations for
> a specific relationship)
> Why is that? I've tried to set the inverse relationship but there are
> no options to choose from.

According to this description, you're not missing one inverse, you're missing 3 
of them: File.parentFile, Child.parentChild and Child.parentFile. If that 
sounds a bit weird that's because your design is a double tree structure with 2 
entities in it.

So one approach is to add the 3 missing 1-1 relationships. (A Child object has 
a parentChild or a parentFile but not both. Or maybe it can have both -- your 
description doesn't exactly rule out that this might be your intention.)

The kind of structure you're trying to model would be easier if Core Data 
allowed mixed entities in a relationship, but it doesn't, so you have to the 
long way round to get the results you want.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to