I have two view controllers, call them viewA and ViewB
- All the action happens in main view –
ViewA - A menu button is hit, brings up
ViewB, all is well and the menu comes up
Now, the user touches one IBAction button, which programmatically just needs to:
- change the value of a
BOOL, call itmyBOOLtoYES - dismiss
ViewB - pass the
myBOOLvariables current state ofYESback toViewA
I have declared the same BOOL, set property, synthesized on both Views, but per my NSLog upon dismissal of ViewB and loading back up ViewA, it reverts back to NO
So I know I’m going off on a tangent, I just want to know if you can send the value of a BOOL between two controllers and if so, please show me an example… as searches have found Protocols and Delegate examples with NSString‘s, and when I attempt with a BOOL I get stuck in an import loop, however I’ve read that its possible to make a global BOOL, as bad design as it is, I just need to get over this block for now.
There is View-independent value keeping tool. You can use:
For example, you inputs strings or datas in A view, you can store them in above variables. And then, in B view, you can use them by below code:
These are a example of
NSUserDefaultsdata using:View A:
View B: