0

I am trying to implement a private method which takes an NSMutableDictionary and a Player object as its parameters. As it is a private method, the only place that it exists is in the ".m" file.

It is declared as

-(void) incrementScore: (NSMutableDictionary*) scoreboard  forPlayer: ( Player* ) player {

and I call it as follows :

      [ self incrementScore:deuceScore forPlayer:p];

However,it won't compile - I get

may not response to message -incrementScore:forplayer

I'm not sure where my error lies - do I need to declare the method in the ".h" file, or elsewhere in the ".m" file, or have I just got the syntax completely wrong?

DaveH
  • 7,187
  • 5
  • 32
  • 53
  • You can easily find your answer here : http://stackoverflow.com/questions/722651/how-do-i-pass-multiple-parameters-in-objective-c – Dimitri Jul 21 '11 at 11:20

2 Answers2

0

This is only a warning not a compile error... (if you changed preferences to treat all warnings like error it'll be a compile error).

Probably the line calling the method is above (in the .m file) the declaration method. Move the method just below @implementation directive, or above the method with the calling line. The warning/error should disapper.

Napoleone1981
  • 107
  • 2
  • 10
0

The compiler needs to find a declaration for your method somewhere before you use it. This be done in three way:

  1. Declare the method in the (public) @interface for the class in its .h file .
  2. Declare the method in a class extension (a semi-private @interface, usually at the top of the .m files).
  3. Define the method somewhere in the @implementation before your first use of it.
一二三
  • 21,059
  • 11
  • 65
  • 74