- Joined
- Mar 9, 2007
- Messages
- 5
- Reaction score
- 0
With no shortage of effort I still can't seem to wrap my head around the Object messaging. This is no usefull application but more a specific challenge I'm trying. I have the window of the Main Nib file set with one button (NSButton) and one text field (NSTextField). When the button is pressed I would like the field to display a string. However, I seek to do this with two seperate subclasses of (NSObject), I've named AFirstClass and ASecondClass. When the button is pressed I would like it to call a method of AFirstClass that calls a method of ASecondClass that displays the string. Both Classes have been instantiated, The button is "connected" with the action messageToSecondAct: and ASecondClass is "connected" with an outlet of type NSTextfield titled textOut. eg. "connections" have been made.
When I build and run the program it goes smoothly until I click the button. There is no response but the run log displays:
2007-03-09 11:03:51.910 HelpExample[5283] *** +[ASecondClass writeOnCommand]: selector not recognized
I understand coding or debugging isn't very enjoyable but I've tried to simplify my problem, and I believe the answer is probably imediatly obviose to the more accomplished. I have included the Interface and implementation files for both classes below:
/* AFirstClass */
#import <Cocoa/Cocoa.h>
@interface AFirstClass : NSObject
{
}
- (IBAction)messageToSecondAct
id)sender;
@end
#import "AFirstClass.h"
#import "ASecondClass.h"
@implementation AFirstClass
- (IBAction)messageToSecondAct
id)sender
{
[ASecondClass writeOnCommand];
}
@end
/* ASecondClass */
#import <Cocoa/Cocoa.h>
@interface ASecondClass : NSObject
{
IBOutlet NSTextField *textOut;
}
+ (void)writeOnCommand;
@end
#import "ASecondClass.h"
@implementation ASecondClass
+ (void)writeOnCommand
{
[textOut setStringValue
"It worked"];
}
@end
When I build and run the program it goes smoothly until I click the button. There is no response but the run log displays:
2007-03-09 11:03:51.910 HelpExample[5283] *** +[ASecondClass writeOnCommand]: selector not recognized
I understand coding or debugging isn't very enjoyable but I've tried to simplify my problem, and I believe the answer is probably imediatly obviose to the more accomplished. I have included the Interface and implementation files for both classes below:
/* AFirstClass */
#import <Cocoa/Cocoa.h>
@interface AFirstClass : NSObject
{
}
- (IBAction)messageToSecondAct
@end
#import "AFirstClass.h"
#import "ASecondClass.h"
@implementation AFirstClass
- (IBAction)messageToSecondAct
{
[ASecondClass writeOnCommand];
}
@end
/* ASecondClass */
#import <Cocoa/Cocoa.h>
@interface ASecondClass : NSObject
{
IBOutlet NSTextField *textOut;
}
+ (void)writeOnCommand;
@end
#import "ASecondClass.h"
@implementation ASecondClass
+ (void)writeOnCommand
{
[textOut setStringValue
}
@end