• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CoreData: filtering controller content
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData: filtering controller content


  • Subject: CoreData: filtering controller content
  • From: Justin Fagnani <email@hidden>
  • Date: Sat, 28 May 2005 11:08:28 -0700

I have some data that's very much like a class hierarchy. Each object has a parent. I have a pop-up button for selecting the parent, but I'd like to remove the target object and any of it's descendants from the list so that there's no possibility of loops.

I guess this is similar to the question I asked a little while ago about getting all descendants in an NSTreeController[1], and will probably have a similar solution, but I've been trying to figure out ways to do this with out writing code using just an additional controller and predicates.

What I think I'm finding is that the predicate syntax is not as well suited for working with trees as other expression languages. XPath, for instance, has the ancestors and descendants axes.

I actually can't even figure out how to filter out the object I'm editing from the list of types. The object is selected in an ArrayController called Types. I want a second ArrayController called ParentTypes to contain all the valid choices for a parent. I figure that I could filter the selected object with a predicate of "self ! = ????" well, what do I put there? Types.selection? The predicate builder for fetched requests has a way to place a variable in the predicate, but I can't seem to compare self to a variable. And the predicate for a controller doesn't have a GUI, so I'm not sure yet how to place a variable. Even then, how do I set that variable?

So this leads me to another solution where I subclass NSManagedObject and create a property called something like objectsNotSelfOrDescendent. To save some work I can add this to my previous subclass and call it a ManagedTreeObject. Ok that's not too bad I guess. However, for some reason I think of this as really extending the behavior of the controller. I'm tempted to subclass NSTreeController and add methods for retrieving objects along the different axes. Good idea or bad idea?

Any thoughts on this?

Thanks,
  -Justin


[1]: http://www.cocoabuilder.com/archive/message/cocoa/2005/5/24/136900

_______________________________________________
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


  • Follow-Ups:
    • Re: CoreData: filtering controller content
      • From: Scott Stevenson <email@hidden>
  • Prev by Date: Re: NSData hexadecimal to 16 bit integer?
  • Next by Date: NSMutableArray with NSMutableDictionaries
  • Previous by thread: Re: NSTableView Context Menu - Select Row
  • Next by thread: Re: CoreData: filtering controller content
  • Index(es):
    • Date
    • Thread