Objective-C Relationship Between Classes

I have an AppController class that looks like the usual way to view / control in my application.

In the main application window in IB, a button appears that forces AppController to create a new window controller (accountPanelController) and display this secondary window:

- (IBAction) showAccountPanel:(id) sender
{
    //Is accountController nil?
    if (!accountPanelController) {
        accountPanelController = [[AccountPanelController alloc] init];
    }

    [accountPanelController showWindow:self];
}

When this new window is completed, I want to send the data collected from my additional window controller to a method in AppController:

- (IBAction) close: (id) sender
{
    NSLog(@"Close detected");
    [AppController addAccount:0];
    [self close];
}

However, when I try to call the addAccount method in AppController from a new window controller, I get that "AppController" may not respond to the warning "+ addAccount".

, -, , AppController , , AppController -addAccount ( + addAccount, ). , + addAccount -addAccount, ( ).

, AppController (, - NIB), - , AppController? ...

.

+3
2

Apple Mac Dev Center: - #Notifications
:
().

, (, +), (-).
, , () AppController (, self ) addAccount:.
.

, , (NSNotification) .

Update:
.

+4

intiWithOtherController :

accountPanelController = [[AccountPanelController alloc] initWithOtherController:self];

, - :

(AccountPanelController *) initWithOtherController:(OtherController *) 

otherController, :

[otherController addAccount:0]
+1

Source: https://habr.com/ru/post/1726497/


All Articles