• 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
How to preserve an NSArrayController's selection when an item's value changes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to preserve an NSArrayController's selection when an item's value changes?


  • Subject: How to preserve an NSArrayController's selection when an item's value changes?
  • From: Matt Gough <email@hidden>
  • Date: Tue, 21 Feb 2006 14:54:48 +0000

I'll do my best to describe this, but will probably omit something important:

Imagine that I have a table view that contains animals. Each animal has a species 'e.g Dog' and a classification 'e.g Mammal'. New animals get added to this table intermittently from an external source. This table is working perfectly, but is needed to explain the next table better.

I have another table which is used to filter the animals displayed in the first table by their classification. E.g The table might consist of:

Mammal
Bird
Fish

The array controller for this table is observing changes to the animals array controller.

When the user clicks on one of the items in this array the animals table nicely updates to show only those animals with the selected classification (by filtering in arrangeObjects).

So imagine we have Bird selected in this list. A new animal comes in from our external source and all the bindings code works nicely to update the animals table controller which causes the classification controller to rebuild its array. As things currently stand, Birds is still selected in the this list and is what I want to happen.

Now onto the problem:

I recently changed the classification controller so that the NSStrings that it keeps in its array also have a bracketed count in them so we can see how many there are of each type:

Mammal (27)
Bird (5)
Fish (12)

If I have the 'Bird (5)' row selected and another bird comes in, then the end result is that although my classification table shows there now being 6 birds, the 'Mammal (27)' row gets selected and the animals table is now showing only mammals, not birds. I am guessing that this happens because the array controller is not able to match up my 'Bird (5)' row with anything, and so it just selects the first row in the table.

So what I need to know is if it is possible to intervene in how NSArrayController tries to match up the selection. Does it all just come down to an isEqualTo test?

Hope that all makes sense

Matt Gough
Softchaos Limited
_______________________________________________
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: How to preserve an NSArrayController's selection when an item's value changes?
      • From: Camillo Lugaresi <email@hidden>
  • Prev by Date: Re: Apple Sample directly accesses ivar. Heresy?
  • Next by Date: Re: How to preserve an NSArrayController's selection when an item's value changes?
  • Previous by thread: Re: NSManagedObjectContext won't save...
  • Next by thread: Re: How to preserve an NSArrayController's selection when an item's value changes?
  • Index(es):
    • Date
    • Thread