instance type checks
This commit is contained in:
parent
d27504ad97
commit
feceef26df
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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 <MVMCoreViewControllerProtocol> *)viewController forLoadObject:(nullable MVMCoreLoadObject *)loadObject presentationDelegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user