This link has two methods, passing into and passing out of. I'm using a database for most of my return values but I found the snippets below to be the most valuable.
http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers
Passing Data INTO a UIViewController
Of course we could skip right to the code:
For this example we will have ViewControllerA and ViewControllerB
To pass a BOOL value from ViewControllerA to ViewControllerB we would do the following.
1) in ViewControllerB.h create a property for the BOOL
@property(nonatomic) BOOL *isSomethingEnabled;
2) in ViewControllerA you need to tell it about ViewControllerB so use an
#import "ViewControllerB.h"
Then where you want to load the view eg. didSelectRowAtIndex or some IBAction you need to set the property in ViewControllerB before you push it onto nav stack.
ViewControllerB *viewControllerB = [[ViewControllerB alloc] initWithNib=@"ViewControllerB" bundle=nil];
viewControllerB.isSomethingEnabled = YES;
[self pushViewController:viewControllerB animated:YES];
No comments:
Post a Comment