我正在學習Objective-C,現在我被困在類別中。下面是代碼Objective-c類別
#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
的問題是,我得到
Returning void from a function with incompatible result type 'NSMutableArray' *
這裏有什麼問題?
我不熟悉目標c。但我想象removeObjectAtIndex返回void。所以我會嘗試[self removeObjectAtIndex:[self count] -1];迴歸自我; – WraithNath 2012-08-06 14:27:34