diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 94211c8..bcce52f 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -36,6 +36,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; @implementation MVMCoreActionHandler + (nullable instancetype)sharedActionHandler { + [MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].actionHandler.class otherClass:self]; return [MVMCoreObject sharedInstance].actionHandler; } diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index bb97f89..bb97de5 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -14,6 +14,7 @@ #import "MVMCoreGetterUtility.h" #import "MVMCoreObject.h" #import "MVMCoreConstants.h" +#import "MVMCoreActionUtility.h" @interface MVMCoreCache () @@ -41,6 +42,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; + (nullable instancetype)sharedCache { + [MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].cache.class otherClass:self]; return [MVMCoreObject sharedInstance].cache; } diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m index be86730..98fa3ac 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m @@ -8,10 +8,12 @@ #import "MVMCoreLoggingHandler.h" #import "MVMCoreObject.h" +#import "MVMCoreActionUtility.h" @implementation MVMCoreLoggingHandler + (nullable instancetype)sharedLoggingHandler { + [MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].loggingDelegate.class otherClass:self]; return [MVMCoreObject sharedInstance].loggingDelegate; } diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionObject.m b/MVMCore/MVMCore/Session/MVMCoreSessionObject.m index b49132d..4855ef1 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionObject.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionObject.m @@ -8,10 +8,12 @@ #import "MVMCoreSessionObject.h" #import "MVMCoreObject.h" +#import "MVMCoreActionUtility.h" @implementation MVMCoreSessionObject + (nullable instancetype)sharedGlobal { + [MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].session.class otherClass:self]; return [MVMCoreObject sharedInstance].session; } diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m index f0f632d..b5ab3ea 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m @@ -18,6 +18,7 @@ #import "MVMCoreRequestParameters.h" #import "NSDictionary+MFConvenience.h" #import "MVMCoreObject.h" +#import "MVMCoreActionUtility.h" @interface MVMCoreSessionTimeHandler () @@ -46,6 +47,7 @@ @implementation MVMCoreSessionTimeHandler + (nullable instancetype)sharedSessionHandler { + [MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].sessionHandler.class otherClass:self]; return [MVMCoreObject sharedInstance].sessionHandler; } diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility.h b/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility.h index a5b4de0..b66375f 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility.h +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility.h @@ -23,4 +23,7 @@ // Can call to display a view controller based on the load object in the same way the architecture does it. Will check the presentation style of the page, action, and request. Will check if needs a view manager. + (void)displayViewController:(nonnull UIViewController *)viewController forLoadObject:(nullable MVMCoreLoadObject *)loadObject presentationDelegate:(nullable NSObject*)delegate completionHandler:(nullable void (^)(void))completionBlock; +// Throws an error if the class is not the same or a subclass of the other class. ++ (void)verifyClassIsInstanceTypeOfClass:(Class)theClass otherClass:(Class)otherClass; + @end diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility.m b/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility.m index 2505762..a05717c 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility.m +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility.m @@ -137,4 +137,10 @@ [[MVMCoreNavigationHandler sharedNavigationHandler] navigateWithLoadObject:loadObject viewController:(viewControllerToLoad ?: viewController) delegate:delegate completionHandler:completionBlock]; } ++ (void)verifyClassIsInstanceTypeOfClass:(Class)theClass otherClass:(Class)otherClass { + if (theClass != otherClass && ![theClass isSubclassOfClass:otherClass]) { + @throw([NSException exceptionWithName:@"NotInstanceType" reason:[NSString stringWithFormat:@"%@ is not an instance of %@",theClass,otherClass] userInfo:nil]); + } +} + @end diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerMappingObject.m b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerMappingObject.m index da84cf2..bc839fc 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerMappingObject.m +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerMappingObject.m @@ -18,6 +18,7 @@ #import "MVMCoreErrorConstants.h" #import "MVMCoreHardcodedStringsConstants.h" #import "MVMCoreObject.h" +#import "MVMCoreActionUtility.h" @interface MVMCoreViewControllerMappingObject () @@ -26,6 +27,7 @@ @implementation MVMCoreViewControllerMappingObject + (nullable instancetype)sharedViewControllerMappingObject { + [MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].viewControllerMapping.class otherClass:self]; return [MVMCoreObject sharedInstance].viewControllerMapping; }