Ramaprasad Upadhyaya
Ramaprasad Upadhyaya

Reputation: 467

Capture child window OK click in parent window- Cocoa/Objective C

I open child window from parent window using below code:

if (!loginWindow) {
        loginWindow = [[LoginController alloc]initWithWindowNibName:@"LoginWindow"];

    }

    [loginWindow showWindow:self];

What I want is, in the child window (loginWindow), If user clicks on OK button, I need to get the response in parent.

ex :

if ([loginWindow showWindow:self] == OK clicked) //THis is just algorithm
{
   //do something
}

How can we achieve this in Cocoa/Objective C?

Upvotes: 0

Views: 379

Answers (2)

Gajendra Rawat
Gajendra Rawat

Reputation: 3663

When You want to some change in a class by firing some action in other class then in this case use delegate method if you know how to use delegate then make a delegate method otherwise follow this link

Upvotes: 1

Lord Zsolt
Lord Zsolt

Reputation: 6557

You need to create a delegate in the child view controller, set the delegate to be the parent view controller, and when the ok button is clicked, you call the delegate method.

Upvotes: 0

Related Questions