I need to fill a UITableView from an NSSet data source. Obviously I want the table sorted by some criteria.
I could simply create a sorted NSArray with [mySet sortedArrayUsing...] and use that for my table data source. But I need something more powerful: The underlying NSSet (mySet) changes over time, and I want the UITableView to update accordingly (still sorted, of course).
My best bet at the moment is to attach observers to the NSSet and refresh the NSArray and the UITableView every time the NSSet changes. It involves quite a bit of code however and is not too efficient.
So what I would like to have is something like this, I guess:
NSArray* sortedWrapperArray = [SortedWrapper wrapperFor:mySet sortUsing:sortCriteria];
where sortedWrapperArray automatically updates when the underlying set changes.
Is there something like this or similiar in the Objective-C/Cocoa world?
If your app will run only on iOS 5.0 or newer, you can use
NSOrderedSet