[英]setting BOOL in viewcontroller from appdelegate
我已經在標題的AppDelegate中定義了BOOL。
AppDelegate.h
BOOL myBool;
@property(nonatomic) BOOL myBool;
並合成它
@synthesize myBool;
我如何從ViewController設置他的值(true或false)?
嘗試這個:
MyAppDelegate* myAppDelegate = (MyAppDelegate*)[[UIApplication sharedApplication] delegate];
myAppDelegate.myBool = true;
(MyAppDelegate *)[[UIApplication sharedApplication] delegate].myBool = YES;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.