Re: How to preserve an NSArrayController's selection when an item's value changes?
Re: How to preserve an NSArrayController's selection when an item's value changes?
- Subject: Re: How to preserve an NSArrayController's selection when an item's value changes?
- From: Camillo Lugaresi <email@hidden>
- Date: Tue, 21 Feb 2006 16:19:44 +0100
On 21/feb/06, at 15:54, Matt Gough wrote:
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?
Most likely, it calls isEqual:. Insted of NSStrings, try using a
custom class. If you can guarantee that the same instance will always
be used for the same category, the implementation of isEqual: in
NSObject should suffice; otherwise, define isEqual: and hash: to call
the corresponding methods of the name string. The category objects
can then have a method that generates the string with name and count,
or you could use the displayWithPattern bindings.
Camillo
_______________________________________________
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