On Dec 4, 2008, at 5:46 PM, Mikael Wämundson wrote:

Hi all.

Since it is good programming to not access an array's content through its controller when in the model I'm trying to find a way to get to the same object selected in the user interface (i.e. the array controller).

In my view I have the array content sorted by binding it to a sort descriptor. Thus, the indices of the array and the content of the array shown in the view differs.

Now, when a certain object is selected in the view I want to do something to this object by accessing it through the original array. My first, perhaps foolish, guess would be to use indexOfObjectIdenticalTo: or indexOfObject: like this:

int indexOfObject = [theOriginalArray indexOfObjectIdenticalTo: [theArrayController selection]];

but this does not work. Looking in the reference I see that [theArrayController selection] will return a proxy object. Is this the reason my code won't work?

Ask the array controller for its' selectedObjects. This returns an array of the selected objects and is not a proxy object like selection. Iterate over that array to get the indexes you're interested in from your original array.


Ashley_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to