Created
October 29, 2012 00:40
-
-
Save Morse-Code/3970703 to your computer and use it in GitHub Desktop.
Method to pass object(s) to child ViewControllers from parent ViewController. In this case a UITabBarController passes a modelobject to each of it's child views that support a given @selector. Container views (ie UINavigationController, UITabBarControlle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.dangerZones = [[DZStoredObjects alloc] init]; | |
// Create a stack and load it with the view controllers from | |
// our tabs. | |
NSMutableArray *stack = [NSMutableArray arrayWithArray:self.viewControllers]; | |
// While we still have items on our stack | |
while ([stack count] > 0) { | |
// pop the last item off the stack. | |
id controller = [stack lastObject]; | |
[stack removeLastObject]; | |
// If it is a container object, add its controllers to | |
// the stack. | |
if ([controller respondsToSelector:@selector(viewControllers)]) { | |
[stack addObjectsFromArray:[controller viewControllers]]; | |
} | |
// If it responds to setWeightHistory, set the weight | |
// history. | |
if ([controller respondsToSelector:@selector(setDangerZones:)]) { | |
[controller setDangerZones:self.dangerZones]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment