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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| @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
Read more