簡體   English   中英

從appdelegate在viewcontroller中設置BOOL

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM