Search code examples
iphoneios5booleanuiapplicationdelegate

setting BOOL in viewcontroller from appdelegate


I've defined a BOOL into my header's AppDelegate.

AppDelegate.h

BOOL myBool;

@property(nonatomic) BOOL myBool;

and synthesize it

@synthesize myBool;

How I'm able to set his value (true or false ) from an ViewController ?


Solution

  • Try this:

    MyAppDelegate* myAppDelegate = (MyAppDelegate*)[[UIApplication sharedApplication] delegate];
    myAppDelegate.myBool = true;