I know this is simple, which is why I've been trying like mad to figure it out myself but I'm at the end of my rope.
When a user clicks a button an action is supposed to do this:
- (IBAction)startAction:(id)sender {
MyClass *anInstance = [[MyClass alloc] init];
NSLog(@"the name is:%@", [anInstance name]);
As you can see, MyClass has the "name" method, which is this:
- (NSString *)name {
return [nameInput stringValue];
NSLog(@"stringValue = %@", [nameInput stringValue]);
nameInput is a text field which the user fills with a name, presses the button to call "startAction", that method should call "name" in another class, which should return the string value from the text field and make the logs.
What is actually happening is that when start is pressed the log says "the name is:(null)". And the second log doesn't even appear. I assume it's because the "name" method isn't getting called. But I don't know why. I should specify that they are in separate classes and I declared the "name" method like this:
- (NSString*)name;
EDIT: After a bit more fooling around I found that when the "name" method gets called from it's own class, the log correctly shows whatever was in the text field. I put an extra log inside the "name" method, and I can see that it is getting called from the other class, but the value it's returning is still (null) which means something is happening after the call that is preventing the class from getting the text field string.
EDIT: I'm not sure if this is important but one of the classes is a subclass of NSObject, the other is a subclass of NSViewController.
Let me know if you need any more information. Thanks for the help.