Re: Re: NSMutableArray, TableView, Bindings and Sorting
Re: Re: NSMutableArray, TableView, Bindings and Sorting
- Subject: Re: Re: NSMutableArray, TableView, Bindings and Sorting
- From: <email@hidden>
- Date: Mon, 26 Jul 2004 16:58:32 -0400
>
From: mmalcolm crawford <email@hidden>
>
>
>
On Jul 26, 2004, at 9:55 AM, email@hidden wrote:
>
> Hmm. The way I did, did return a sorted array.
>
>
From your original post:
>
>
> what's the best way of sorting the actual array, and making sure the
>
> table view is updated - or
>
> making sure the array is sorted, when the column table heading is
>
> clicked.
>
>
My understanding of the question is that you want to know the "correct"
>
way to implement sorting in the table view using the array
>
controller(*)? The correct way is to implement -arrangeObjects:, which
>
will then be called as and when necessary.
>
Yes, sort of.. Given the original sample code, which had no special routines
to deal with sorting, when clicking on the table column headings, the table
view did sort, which is great. My original question was, if after sorting the
tableview, I wanted to be able to access my array the way it was sorted.
In digging more, I was able to figure out that I could just access the
arrangedObjects item of the array controller, and enumerate through that.
That gives the objects in the tableview-order.
If I wanted to, in a "real" application be able to access my array in whatever
order (to print out a report, for example with subtotals, etc.), I could then just
use the NSArray's sorting routines to get a copy of the array in the order I
want.
I suppose I'm still a little fuzzy - if I had a table (bound to an
NSMutableArray of my objects) with more columns, and I wanted to do a
multi-level sort, in response to a menu selection, or a button click, I'm not
sure how I sort the array, then update the table view.
>
> Which example shows sorting? I can't see which one does.
>
>
>
The examples in the section "Filtering Array Controller + Object
>
Initlialisation", and the last two (Combatants and many-to-many) show
>
the use of arrangeObjects...
>
>
(*) I'm also assuming that there's no way to get automatic sorting
>
using the Sort {Key, Selector, Order} on the table column.
>
>
mmalc
>
Thanks.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.