A class "A" may not respond to a method of the class "B"
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