Skip navigation.
 
mlRe: NSSortDescriptor not working with array of custom classes
FROM : Shawn Erickson
DATE : Mon Nov 05 02:07:46 2007

On Nov 4, 2007, at 3:25 PM, Ken Tozier wrote:

>
> On Nov 4, 2007, at 6:05 PM, Shawn Erickson wrote:
>

>> Can you post a complete code sample that shows the problem you are 
>> reporting. We are having to guess at what your class(es) involved 
>> really look like. You can simplify it down to some thing that shows 
>> the issue you having.

>
> That last post was pretty much where the problem is, but here's a 
> couple of other methods to flesh it in
>
> - (void) sortPageViews
> {
>     NSLog(@"pages before sortine: %@, class: %@", pages, [pages class]);


Which class is sortPageViews in? What does pages contain?

>     NSArray                *sortedCells        = [pages sortedArrayUsingDescriptors: desc];


>     [pages release];
>     pages                = [[sortedCells mutableCopy] retain];


Why not use -[NSMutableArray sortUsingDescriptors] instead of the 
above? Also in the above you copy and retain sortedCells so you are 
ending up with an extra retain that isn't balanced by the one release 
in the above.

-Shawn

Related mailsAuthorDate
mlRe: NSSortDescriptor not working with array of custom classes Ken Tozier Nov 4, 23:50
mlRe: NSSortDescriptor not working with array of custom classes Shawn Erickson Nov 5, 00:05
mlRe: NSSortDescriptor not working with array of custom classes Ken Tozier Nov 5, 00:25
mlRe: NSSortDescriptor not working with array of custom classes Shawn Erickson Nov 5, 02:07