• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
A class "A" may not respond to a method of the class "B"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A class "A" may not respond to a method of the class "B"


  • Subject: A class "A" may not respond to a method of the class "B"
  • From: Angel Manuel Mariblanca Gonzalez <email@hidden>
  • Date: Sun, 11 Jan 2009 02:19:37 +0100

Hello!
I'm new developing for Mac, I'm starting, and I've got a problem with methods and class.
I have a class (RandomGenerator) that I created to be a random generator (obvious). This class have one method:

RandomGenerator.h****************
#import <Cocoa/Cocoa.h>
@interface RandomGenerator : NSObject 
{
int range;
}
- (int)  randomNumber: (int) withRange;
RandomGenerator.m****************
@implementation RandomGenerator
- (int) randomNumber: (int) withRange
{
if (range<1)
{
return 0;
} else 
{
int random_number=(random() % range)+1; 
return random_number;
}
}
@end


I have another class (Controller) to control the rest of the program. I tried to use the method randomNumber in this class, but doesn't work.

Controller.h****************
#import <Cocoa/Cocoa.h>
@interface Controller : NSObject 
{

    IBOutlet NSTextField *Text_field;

}
- (IBAction)showRandom:(id)sender;
@end
Controller.m****************
#import "Controller.h"
#import "RandomGenerator.h"
@implementation Controller
- (IBAction)showRandom:(id)sender
{

[Text_field setIntValue:[self randomNumber:115]];

}

@end

The message of error is: 
warning:'Controller' may not respond to '-randomNumber'.
(Messages without a matching method signature will be assumed to return 'id' and accept '...' as argument).

What could be the cause of this error? 
Thanks.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: A class "A" may not respond to a method of the class "B"
      • From: Alexander Heinz <email@hidden>
    • Re: A class "A" may not respond to a method of the class "B"
      • From: Andrew Pontious <email@hidden>
  • Prev by Date: Re: Program compiles, but does not run
  • Next by Date: Re: A class "A" may not respond to a method of the class "B"
  • Previous by thread: Re: IB no longer works with xibs in 3.1.2 [solved]
  • Next by thread: Re: A class "A" may not respond to a method of the class "B"
  • Index(es):
    • Date
    • Thread