Monthly Archives: February 2011

Objective-C Warning: ‘class’ may not respond to ‘-message:’

If you get a warning of this form:

warning: ‘Class’ may not respond to ‘-message:’
(Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)

There are a few things to check:

  1. Make sure that you spelled the name of the message correctly, and that you matched all of the types of all of the arguments
  2. If the message is called in the same class, then the message you call must be higher in the class or the message must be declared in the header
  3. If you are calling it from a different class, then the message must be declared in the header

Remember, the declaration of the message must match the actual message signature. For example, if you have a message like this:

-(void) message:(NSString *)value
{
// message implementation
}

Then, you need this in your header:

-(void) message:(NSString *)value; // don’t forget the semicolon

Get iPhone programming tips in your inbox with my Beginner iPhone Programming Tips newsletter.