0

Here is my problem. I have an NSTextField connected to my app delegate. Then i have a CustomView in my MainManu.xib associated with a new class i created, "myView", sublass of NSView. finally a Button that trigger an action declared in myView.h. (i drag n drop from button to the custom view and selected the action pushFromView) This action is implemented in myView.m in this way:

 -(IBAction)pushFromView:(id)sender{
    [self.myApp getMeFromView];
}

myApp is an instance of AppDelegate that contain the method getMeFromView which is supposed to get the text from the textfield and log it.

#import "GTAppDelegate.h"

@implementation GTAppDelegate
@synthesize myText;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
}  

-(void)getMeFromView{
    NSLog(@"valuefromView= %d",[myText intValue]);
}
@end

Now anytime i press the button it trigger the method but even if the textfield is filled with numbers it returns me zero. Instead if i create a button connected with an action in appDelegate it works properly.

an instance of myApp is declared in myView header and the property as well.

Im kinda rookie, so maybe I explained myself in a non proper way. I hope you can get it. Thanks in advance for your help.

Luca

1 Answers1

0

Use just [myApp getMeFromView] instead of [self.myApp getMeFromView].

moray95
  • 937
  • 2
  • 9
  • 12