获取的方法,我有一些类:目标C:问题与
@interface SearchBase : NSObject
{
NSString *words;
NSMutableArray *resultsTitles;
NSMutableArray *resultsUrl;
NSMutableArray *flag;
}
@property (copy, nonatomic) NSString *words;
- (id) getTitleAtIndex:(int *)index;
- (id) getUrlAtIndex:(int *)index;
- (id) getFlagAtIndex:(int *)index;
@end
@implementation SearchBase
- (id) initWithQuery:(NSString *)words
{
if (self = [super init])
{
self.words = words;
}
return self;
}
- (id) getTitleAtIndex:(int *)index
{
return [resultsTitles objectAtIndex:index];
}
- (id) getUrlAtIndex:(int *)index
{
return [resultsUrl objectAtIndex:index];
}
- (id) getFlagAtIndex:(int *)index
{
return [flag objectAtIndex:index];
}
@end
但是,当我试图使用在子类中一些获得的方法,我看到:
warning: passing argument 1 of 'getTitleAtIndex:' makes pointer from integer without a cast
warning: passing argument 1 of 'getFlagAtIndex:' makes pointer from integer without a cast
warning: passing argument 1 of 'getUrlAtIndex:' makes pointer from integer without a cast
程序无法正常工作。怎么了?如何解决它?
仅供参考,可可约定对这些方法不使用“get”前缀。只需使用'titleAtIndex:'和'urlAtIndex:'之类的东西。 –