Vitor Franchi's answer is correct, but can be more efficient and convenient. Especially when accessing the childhood viewing controller several times.
Create readonly property
@interface MyViewController () @property (nonatomic, weak, readonly) InstallViewController *cachedInstallViewController; @end
Then create a convenient getter method
- (InstallViewController *)installViewController { if (_cachedInstallViewController) return _cachedInstallViewController; __block InstallViewController *blockInstallViewController = nil; NSArray *childViewControllers = self.childViewControllers; [childViewControllers enumerateObjectsUsingBlock:^(id childViewController, NSUInteger idx, BOOL *stop) { if ([childViewController isMemberOfClass:InstallViewController.class]) { blockInstallViewController = childViewController; *stop = YES; } }]; _cachedInstallViewController = blockInstallViewController; return _cachedInstallViewController; }
Now access to the child view controller in this way
[self.installViewController doSomething]
Martin Stolz Mar 31 '14 at 10:53 2014-03-31 10:53
source share