I spent quite a few hours on this but could not resolve it. I follow this basic tutorial to create cocoa mac os application that has
I created a new class, added NSString object, change the class name for NSString object to my class. Then I control+dragged text box, label to myclass.h (outlets). I did the same to button but this time selected action.
Now I put code in action to acess my label, I can't. They do not appear in intellesense. I have spent quite sometime on this. This is a very basic qeustion. what am I doing wrong? i am using XCODE 4.6.3.
------------------- .h file ---------------------
#import <Foundation/Foundation.h>
@interface myclass : NSObject
- (IBAction)doSomething:(id)sender;
@property (weak) IBOutlet NSView *mytextbox;
@property (weak) IBOutlet NSTextField *mylabel;
@end
----------------- .c file ---------------------------
#import "myclass.h"
@implementation myclass
- (IBAction)doSomething:(id)sender {
[self.mytextbox.value setStringValue:@"hello there"];
[mytextbox] (not accessible)
}
@end
---------------------------------------------
The trick here was, I had to use underscore character before the variable (property) name. I don't know how why underscore work with and what is its purpose. I am new to xcode. So
_mytextbox //worked