Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the correct way to call IBAction from different controller?
    primarykey
    data
    text
    <p>It's about objective c and cocoa</p> <p>I've faced a problem and don't know how to solve it. Hope I can find answer here and it will be helpful for some other programmers.</p> <p>So, I have a simple window with 4 elements:</p> <ol> <li>NSTextField - first field to set value </li> <li>NSButton - to set value in first field </li> <li>NSTextField - second field to set value</li> <li>NSButton - to set value in second field</li> </ol> <p>here is "controller 1" code:</p> <pre><code>#import "controller2.h" @interface controller1 : NSControl{ IBOutlet NSTextField * text1; } -(IBAction)click:(id)sender; @end @implementation controller1 -(IBAction)click:(id)sender { [text1 setStringValue:@"text1 changed"]; // create controller 2 instance controller2 * c2 = [[[controller2 alloc] init] autorelease]; // call first time using one way [c2 click:self]; // call second time using another way [self sendAction:@selector(click:) to:c2]; } @end </code></pre> <p>and controller 2 code:</p> <pre><code>@interface controller2 : NSControl{ IBOutlet NSTextField * text2; } -(IBAction)click:(id)sender; @end @implementation controller2 -(IBAction)click:(id)sender { [text2 setStringValue:@"text 2 changed"]; NSLog(@"Test2"); } @end </code></pre> <p>when I click on button1 I rase "click" in controller1 - everything is fine and work correct</p> <p>when I click on button2 I rase "click" in controller2 - everything is fine and work correct</p> <p>BUT if I want to click button1 and rase "click" in controller2 it doesn't work (</p> <p>Can anyone help with it? It seems to have a very simple resolution but i don't know what i did wrong.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload