Ok here is an interesting one... I am receiving the
warning: Characters may not respond to 'addHeroType:atX:atY:fromMobTable'
although I have the functions defined properly as far as I can see so how about another pair of 开发者_StackOverflow中文版eyes?
Here is the definition in Characters.h
-(void) addHeroType:(int)newMobType atX:(int)x atY:(int)y fromMobTable:(Mobdefs*)newMobTable;
Here is the function in the Characters.m
-(void) addHeroType:(int)newMobType atX:(int)x atY:(int)y fromMobTable:(Mobdefs*)newMobTable
and here is the call I am making in another class call heroFactory (Characters.h
is included in heroFactory):
[Characters addHeroType:1 atX:location.x atY:location.y fromMobTable:newMobTable];
But this line causes the app to terminate due to uncaught exception - checking the debugger I see "NSObject Does Not Recognize Selector"
I am convinced that the issue is the wierdness of why I am seeing a warning that the Character class may not respond to the function call as written even though it matches identically to the definition.
Any help greatly appreciated.
-(void) addHeroType:(int)newMobType atX:(int)x atY:(int)y fromMobTable:(Mobdefs*) newMobTable
That is declared as an instance method.
[Characters addHeroType:1 atX:location.x atY:location.y fromMobTable:newMobTable];
But you are calling it on the class as a class method.
So either, declare the method as a class method
+(void) addHeroType:(int)newMobType atX:(int)x atY:(int)y fromMobTable:(Mobdefs*) newMobTable
Or call it on an instance
Characters *instance = [[[Characters alloc] init] autorelease];
[instance addHeroType:1 atX:location.x atY:location.y fromMobTable:newMobTable];
Depending on the scope your method requires, of course.
精彩评论