In a nutshell what my program does is: it executes and takes user input periodically using nswindow (which is controlled by my NSWindowController object) and continues execution.
here is my myController.mm which is calling and showing the window to take user input:
EncryptPasswordDlgController encPassController = [[EncryptPasswordDlgController alloc] init];
[encPassController showWindow:self];
NSString *inputPassword = [encPassController password];
here is my nswindowcontroller object code:
#import "EncryptPasswordDlgController.h"
@implementation EncryptPasswordDlgController
-(id) init
{
return self;
}
- (IBAction)showWindow:(id)sender
{
[super showWindow:sender];
encryptPasswordDlgWindowController = [[NSWindowController alloc] initWithWindowNibName:@"EncryptionPasswordDlg"];
[encryptPasswordDlgWindowController loadWindow];
[[self window] makeKeyAndOrderFront:[self window]];
return;
}
-(IBAction)clickOK:(id) sender
{
password = [passwordField stringValue];
NSLog(@"password is %@", password);
[[self window] close];
return;
}
-(NSString *)password
{
return password;
}
-(IBAction)clickCancel:(id) sender
{
// close the window
password = nil;
[[self window] close];
//return;
}
@end
after i click the ok or cancel button, the respective IBAction method is getting called and is getting executed as required i.e it is showing the window taking user input from text field and on clicking ok it is updating the password also. But after it finishes execution of IBAction clickOK method, it should return back to myController.mm and retrieve the password by executing the next statement "NSString *inputPassword = [encPassController password];" which is not happening. Please can anone suggest a way to tackle this situation.