[ Cocoa / Objective-C: Access a (Boolean) variable in different Classes ]
Situation: Noob / Xcode 3.1
I have an AppView (NSView subclass) and an AppController (NSObject subclass)
in AppView.h i declare a boolean (BOOL: booleanDraw), which i set to 'NO' in AppView.m
When a button is clicked it 'launches' an action (AppController .h/.m) now i want to change booleanDraw to YES when the button is clicked.
I searched and found: do it with @property okay i tried to do that but it didnt work. (because i didnt totally get what to do probably) i did:
@property BOOL booleanDraw;
@implementation AppView @synthesize(readwrite, nonatomic) booleanDraw;
AppView *obj; obj.booleanDraw = YES; // implicitly calls [obj setVar:3]
Thanks for any help, i read some tutorials already but often they suggest some steps that should be basic but that dont belong to my repertoire, and the ADN often confuse me xD sorry but believe me im trying^^
You just reversed the synthesize and property statements:
@property (nonatomic) booleanDraw;
(by default properties are readwrite, you only need to state when they are readonly)
In the controller you need to get the app view reference, the code you posted would not work unless you set "obj" to something.