objective c - can't get form access from my class -


#import <foundation/foundation.h>  @interface myclass : nsobject { @private     iboutlet nstextfield *tf; } - (void)setstr;  @end  ===========================================  #import "myclass.h"  @implementation myclass  - (id)init {     self = [super init];     if (self) {         // initialization code here.     }      return self; }  - (void)dealloc {     [super dealloc]; }  - (void)setstr {     [tf setstringvalue:@"aaaaaaaaa"]; }  @end 

call method appdelegate class

- (ibaction)test1:(id)sender {      myclass *m = [[myclass alloc] init];      [m setstr]; } 

i created object of myclass in .xib file. correlated outlet of textfield textfield on form. , there no actions when button pressed. i'm wrong?

you need create outlet myclass in appdelegate , connect up, use outlet in test1 instead of creating new instance. guide apple should you.

another possibility put test1 action myclass , have called directly button press, or make setstr ibaction. these possible, since have myclass instance in xib.


Comments