instance type checks
This commit is contained in:
parent
d27504ad97
commit
feceef26df
@ -36,6 +36,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
|||||||
@implementation MVMCoreActionHandler
|
@implementation MVMCoreActionHandler
|
||||||
|
|
||||||
+ (nullable instancetype)sharedActionHandler {
|
+ (nullable instancetype)sharedActionHandler {
|
||||||
|
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].actionHandler.class otherClass:self];
|
||||||
return [MVMCoreObject sharedInstance].actionHandler;
|
return [MVMCoreObject sharedInstance].actionHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#import "MVMCoreGetterUtility.h"
|
#import "MVMCoreGetterUtility.h"
|
||||||
#import "MVMCoreObject.h"
|
#import "MVMCoreObject.h"
|
||||||
#import "MVMCoreConstants.h"
|
#import "MVMCoreConstants.h"
|
||||||
|
#import "MVMCoreActionUtility.h"
|
||||||
|
|
||||||
@interface MVMCoreCache ()
|
@interface MVMCoreCache ()
|
||||||
|
|
||||||
@ -41,6 +42,7 @@
|
|||||||
static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
||||||
|
|
||||||
+ (nullable instancetype)sharedCache {
|
+ (nullable instancetype)sharedCache {
|
||||||
|
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].cache.class otherClass:self];
|
||||||
return [MVMCoreObject sharedInstance].cache;
|
return [MVMCoreObject sharedInstance].cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,12 @@
|
|||||||
|
|
||||||
#import "MVMCoreLoggingHandler.h"
|
#import "MVMCoreLoggingHandler.h"
|
||||||
#import "MVMCoreObject.h"
|
#import "MVMCoreObject.h"
|
||||||
|
#import "MVMCoreActionUtility.h"
|
||||||
|
|
||||||
@implementation MVMCoreLoggingHandler
|
@implementation MVMCoreLoggingHandler
|
||||||
|
|
||||||
+ (nullable instancetype)sharedLoggingHandler {
|
+ (nullable instancetype)sharedLoggingHandler {
|
||||||
|
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].loggingDelegate.class otherClass:self];
|
||||||
return [MVMCoreObject sharedInstance].loggingDelegate;
|
return [MVMCoreObject sharedInstance].loggingDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,12 @@
|
|||||||
|
|
||||||
#import "MVMCoreSessionObject.h"
|
#import "MVMCoreSessionObject.h"
|
||||||
#import "MVMCoreObject.h"
|
#import "MVMCoreObject.h"
|
||||||
|
#import "MVMCoreActionUtility.h"
|
||||||
|
|
||||||
@implementation MVMCoreSessionObject
|
@implementation MVMCoreSessionObject
|
||||||
|
|
||||||
+ (nullable instancetype)sharedGlobal {
|
+ (nullable instancetype)sharedGlobal {
|
||||||
|
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].session.class otherClass:self];
|
||||||
return [MVMCoreObject sharedInstance].session;
|
return [MVMCoreObject sharedInstance].session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#import "MVMCoreRequestParameters.h"
|
#import "MVMCoreRequestParameters.h"
|
||||||
#import "NSDictionary+MFConvenience.h"
|
#import "NSDictionary+MFConvenience.h"
|
||||||
#import "MVMCoreObject.h"
|
#import "MVMCoreObject.h"
|
||||||
|
#import "MVMCoreActionUtility.h"
|
||||||
|
|
||||||
@interface MVMCoreSessionTimeHandler ()
|
@interface MVMCoreSessionTimeHandler ()
|
||||||
|
|
||||||
@ -46,6 +47,7 @@
|
|||||||
@implementation MVMCoreSessionTimeHandler
|
@implementation MVMCoreSessionTimeHandler
|
||||||
|
|
||||||
+ (nullable instancetype)sharedSessionHandler {
|
+ (nullable instancetype)sharedSessionHandler {
|
||||||
|
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].sessionHandler.class otherClass:self];
|
||||||
return [MVMCoreObject sharedInstance].sessionHandler;
|
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.
|
// 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;
|
+ (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
|
@end
|
||||||
|
|||||||
@ -137,4 +137,10 @@
|
|||||||
[[MVMCoreNavigationHandler sharedNavigationHandler] navigateWithLoadObject:loadObject viewController:(viewControllerToLoad ?: viewController) delegate:delegate completionHandler:completionBlock];
|
[[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
|
@end
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#import "MVMCoreErrorConstants.h"
|
#import "MVMCoreErrorConstants.h"
|
||||||
#import "MVMCoreHardcodedStringsConstants.h"
|
#import "MVMCoreHardcodedStringsConstants.h"
|
||||||
#import "MVMCoreObject.h"
|
#import "MVMCoreObject.h"
|
||||||
|
#import "MVMCoreActionUtility.h"
|
||||||
|
|
||||||
@interface MVMCoreViewControllerMappingObject ()
|
@interface MVMCoreViewControllerMappingObject ()
|
||||||
|
|
||||||
@ -26,6 +27,7 @@
|
|||||||
@implementation MVMCoreViewControllerMappingObject
|
@implementation MVMCoreViewControllerMappingObject
|
||||||
|
|
||||||
+ (nullable instancetype)sharedViewControllerMappingObject {
|
+ (nullable instancetype)sharedViewControllerMappingObject {
|
||||||
|
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].viewControllerMapping.class otherClass:self];
|
||||||
return [MVMCoreObject sharedInstance].viewControllerMapping;
|
return [MVMCoreObject sharedInstance].viewControllerMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user