diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h index 02487e0..fc03b06 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h @@ -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 diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m index 8547285..a47a583 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m @@ -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 *)createViewController { - return [[self.viewControllerClass alloc] init]; + UIViewController *newController = [[self.viewControllerClass alloc] init]; + if (self.configureHandler) { + self.configureHandler(newController); + } + return newController; } @end