【问题标题】:setting BOOL in viewcontroller from appdelegate从 appdelegate 在 vi​​ewcontroller 中设置 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;

      【讨论】:

        猜你喜欢
        • 2017-07-16
        • 1970-01-01
        • 2020-10-21
        • 1970-01-01
        • 1970-01-01
        • 2016-07-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多