Re: NSTreeController / CoreData question [Solved]
Re: NSTreeController / CoreData question [Solved]
- Subject: Re: NSTreeController / CoreData question [Solved]
- From: Scott Stevenson <email@hidden>
- Date: Tue, 24 May 2005 18:24:06 -0700
On May 24, 2005, at 3:46 PM, Justin Fagnani wrote:
Another options is to create a "topLevelCategory" attribute and
override the set mutators for Category, so that every time an item is
added, you can do something like:
[item setValue: [self valueForKey:@"topLevelCategory"] forKey:
@"topLevelCategory"]];
Then you can add a fetched property to Category for all items that
match "topLevelCategory == %@", self.
Even though I got it working, I'm still interested in what you are
saying here. Unfortunately, I don't think I understand what's
happening here. It looks like topLevelCategory points to exactly
what the name says, but if I selected a 3rd level category I'd
still get all the items from it's top-level category, not the items
from the selected categories descendants.
Ah, you're right. I think I misunderstood what you were looking for.
Instead, you'd have the following:
1. A to-many "ancestors" relationship for Category and a to-one
"parent" relationship for both Item and Category.
Category
parent
ancestors
Item
parent
2. Each time a child Category is added, its "ancestors" relationship
is set to (parent's ancestors + parent itself).
The predicate for the fetched property "recursivelyContainedItems" on
Category would read like:
"all items whose parent NOT IN ( my ancestors )"
I haven't tried this but it seems like it should work.
- Scott
--
http://treehouseideas.com/
http://theocacao.com/ [blog]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden