• 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
Re: Using an arraycontroller for different object classes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using an arraycontroller for different object classes


  • Subject: Re: Using an arraycontroller for different object classes
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 14 May 2009 22:51:47 -0500

On May 14, 2009, at 7:07 PM, Gideon King wrote:

Hi, I have a situation where I have an array of objects that I want to bind to so I can use them in an inspector, but the objects are of different classes, and I want the inspector to only see the objects that have the key that I am binding to.

For example, if I have an array of vehicles, and this array contains 4 car objects and 2 bulldozer objects. Now I want to have in my inspector a binding for weight, and one for tyre size.

So for the binding for weight, it is applicable to both classes - they both have an instance variable called "weight", so the array would contain 6 objects, but for the binding for tyre size, the bulldozers don't have tyres, so the array would only have 4 objects in it.

How should I approach this issue? It appears that the filter predicates are set on the whole array and would affect everything, and I have no way to set them based on the key that is being accesses.

Filter predicates are set on array controllers, not arrays.

Something is controlling what key the inspector is using. Whenever that decision is made, you can change the filter predicate. You can do that programmatically with -setFilterPredicate:. You could also bind the array controller's filter predicate binding to a property of a coordinating controller, and change that property.

If you have multiple views which are displaying the array, and you want most to continue showing all of the elements with only the inspector showing a subset, then you will need multiple array controllers -- one which is presenting the whole list and another which is presenting the filtered subset.

Regards,
Ken

_______________________________________________

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


  • Follow-Ups:
    • Re: Using an arraycontroller for different object classes
      • From: Gideon King <email@hidden>
References: 
 >Using an arraycontroller for different object classes (From: Gideon King <email@hidden>)

  • Prev by Date: Re: Class Singleton Instantiation
  • Next by Date: Re: NSCFArray autoreleased with no pool in place
  • Previous by thread: Using an arraycontroller for different object classes
  • Next by thread: Re: Using an arraycontroller for different object classes
  • Index(es):
    • Date
    • Thread