Issue #97
The Coordinator pattern can be useful to manage dependencies and handle navigation for your view controllers. It can be seen from BackchannelSDK-iOS, take a look at BAKCreateProfileCoordinator for example
@implementation BAKCreateProfileCoordinator
- (instancetype)initWithUser:(BAKUser *)user navigationController:(UINavigationController *)navigationController configuration:(BAKRemoteConfiguration *)configuration {
self = [super init];
if (!self) return nil;
_navigationController = navigationController;
_user = user;
_profileViewController = [[BAKProfileFormViewController alloc] init];
[self configureProfileForm];
_configuration = configuration;
return self;
}
- (void)start {
[self.profileViewController updateDisplayName:self.user.displayName];
[self.navigationController pushViewController:self.profileViewController animated:YES];
}
- (void)profileViewControllerDidTapAvatarButton:(BAKProfileFormViewController *)profileViewController {
BAKChooseImageCoordinator *imageChooser = [[BAKChooseImageCoordinator alloc] initWithViewController:self.navigationController];
imageChooser.delegate = self;
[self.childCoordinators addObject:imageChooser];
[imageChooser start];
}
- (void)imageChooserDidCancel:(BAKChooseImageCoordinator *)imageChooser {
[self.childCoordinators removeObject:imageChooser];
}
Look how it holds navigationController
as root element to do navigation, and how it manages childCoordinators