【问题标题】:setting BOOL in viewcontroller from appdelegate从 appdelegate 在 viewcontroller 中设置 BOOL
【发布时间】:2011-11-09 09:28:18
【问题描述】:
我在标题的 AppDelegate 中定义了一个 BOOL。
AppDelegate.h
BOOL myBool;
@property(nonatomic) BOOL myBool;
合成它
@synthesize myBool;
如何从 ViewController 设置他的值(true 或 false)?
【问题讨论】:
标签:
iphone
ios5
boolean
uiapplicationdelegate
【解决方案1】:
试试这个:
MyAppDelegate* myAppDelegate = (MyAppDelegate*)[[UIApplication sharedApplication] delegate];
myAppDelegate.myBool = true;
【解决方案2】:
(MyAppDelegate *)[[UIApplication sharedApplication] delegate].myBool = YES;