I’m learning Objective-C and now I’m stuck with categories. Here is the code
#import <Foundation/Foundation.h>
@interface NSMutableArray (NSMutableArrayCategory)
-(NSMutableArray *)removeLastObject;
@end
#import "NSMutableArrayCategory.h"
@implementation NSMutableArray (NSMutableArrayCategory)
-(NSMutableArray *)removeLastObject
{
return [self removeObjectAtIndex:[self count] - 1];
}
@end
The problem is that I get
Returning void from a function with incompatible result type 'NSMutableArray' *
What is wrong here ?
You probably want to declare
removeLastObjectas returningvoid, notNSMutableArray.Then the implementation will look like this:
This matches the other mutation methods on
NSMutableArray.