enhance controller registration to allow for configuration
This commit is contained in:
parent
11d7fcb4d7
commit
147a237ba9
@ -13,7 +13,11 @@
|
||||
// View Controller Class, for loading by class.
|
||||
@property (nonnull, strong, nonatomic) Class viewControllerClass;
|
||||
|
||||
@property (nullable, copy, nonatomic) void (^configureHandler)(UIViewController * _Nonnull);
|
||||
|
||||
// Initializes with the given class.
|
||||
- (nullable id)initWithClass:(nonnull Class)viewControllerClass;
|
||||
|
||||
- (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^_Nonnull)(UIViewController * _Nonnull))configureBlock;
|
||||
|
||||
@end
|
||||
|
||||
@ -19,8 +19,20 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^)(UIViewController * _Nonnull))configureBlock {
|
||||
self = [self initWithClass:viewControllerClass];
|
||||
if (self) {
|
||||
self.configureHandler = configureBlock;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable UIViewController <MVMCoreViewControllerProtocol> *)createViewController {
|
||||
return [[self.viewControllerClass alloc] init];
|
||||
UIViewController <MVMCoreViewControllerProtocol> *newController = [[self.viewControllerClass alloc] init];
|
||||
if (self.configureHandler) {
|
||||
self.configureHandler(newController);
|
||||
}
|
||||
return newController;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user