views:

127

answers:

1

I have the following class:

typedef enum eItems {
kItem1,
kItem2,
kItem3  
} MyItem;

@interface MyClass: CCSprite<CCTargetedTouchDelegate>{
... 
MyItem mClIt;
...
}

...
- (NSComparisonResult)MyCompareFunc:(MyClass*)inObject
- (MyItem)GetSomeItem;
...

And function for sorting:

- (NSComparisonResult)MyCompareFunc:(MyClass*)inObject
{
 if ([self GetSomeItem] > [inObject GetSomeItem])
    return NSOrderedDescending;
 else if ([self GetSomeItem] < [inObject GetSomeItem])
    return NSOrderedAscending;
 return NSOrderedSame;
}

I create the NSArray of the MyClass objects later in the some class:

@interface Person : Main {
    ....
    NSArray * mObjArr;
    ....
}

And I need to sort the mObjArr with help of MyCompareFunc, using sortUsingSelector:@selector(MyCompareFunc:) method. But I have the following error:

error: accessing unknown 'mObjArr' getter method.

Help please to resolve the problem.

+1  A: 

I'm not sure if this is the only problem, but you'd need an NSMutableArray, not NSArray, to use sortUsingSelector:.

JWWalker
Thanks it was the problem
Romula