Merge branch 'feature/controller_configuration' into 'develop'
enhance controller registration to allow for configuration See merge request BPHV_MIPS/mvm_core!122
This commit is contained in:
commit
4f54c125a6
@ -10,10 +10,16 @@
|
||||
|
||||
@interface MVMCoreViewControllerProgrammaticMappingObject : NSObject <MVMCoreViewControllerMappingProtocol>
|
||||
|
||||
// View Controller Class, for loading by class.
|
||||
/// View Controller Class, for loading by class.
|
||||
@property (nonnull, strong, nonatomic) Class viewControllerClass;
|
||||
|
||||
// Initializes with the given class.
|
||||
/// Configuration block executed on creation of the controller before loading.
|
||||
@property (nullable, copy, nonatomic) void (^configureHandler)(UIViewController * _Nonnull);
|
||||
|
||||
/// Initializes with the given class.
|
||||
- (nullable id)initWithClass:(nonnull Class)viewControllerClass;
|
||||
|
||||
/// Initializes with the given class. Assigns a configuration block triggered on intiailization which allows additional configuration of the view controller before its loaded, i.e. injecting top level dependencies.
|
||||
- (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