fix to class check for nil
convenience functions init functions
This commit is contained in:
parent
88b18372c8
commit
edf59e0e78
@ -36,8 +36,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
@implementation MVMCoreActionHandler
|
||||
|
||||
+ (nullable instancetype)sharedActionHandler {
|
||||
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].actionHandler.class otherClass:self throwException:YES];
|
||||
return [MVMCoreObject sharedInstance].actionHandler;
|
||||
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].actionHandler classToVerify:self];
|
||||
}
|
||||
|
||||
- (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||
|
||||
@ -42,8 +42,7 @@
|
||||
static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
||||
|
||||
+ (nullable instancetype)sharedCache {
|
||||
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].cache.class otherClass:self throwException:YES];
|
||||
return [MVMCoreObject sharedInstance].cache;
|
||||
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].cache classToVerify:self];
|
||||
}
|
||||
|
||||
- (nullable instancetype)init {
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
@implementation MVMCoreLoggingHandler
|
||||
|
||||
+ (nullable instancetype)sharedLoggingHandler {
|
||||
if ([MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].loggingDelegate.class otherClass:self throwException:NO]) {
|
||||
if ([MVMCoreObject sharedInstance].loggingDelegate && [MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].loggingDelegate.class otherClass:self throwException:NO]) {
|
||||
return (MVMCoreLoggingHandler *)[MVMCoreObject sharedInstance].loggingDelegate;
|
||||
} else {
|
||||
return nil;
|
||||
|
||||
@ -13,8 +13,7 @@
|
||||
@implementation MVMCoreSessionObject
|
||||
|
||||
+ (nullable instancetype)sharedGlobal {
|
||||
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].session.class otherClass:self throwException:YES];
|
||||
return [MVMCoreObject sharedInstance].session;
|
||||
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].session classToVerify:self];
|
||||
}
|
||||
|
||||
- (nullable NSDictionary *)getInitialParameters {
|
||||
|
||||
@ -47,8 +47,7 @@
|
||||
@implementation MVMCoreSessionTimeHandler
|
||||
|
||||
+ (nullable instancetype)sharedSessionHandler {
|
||||
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].sessionHandler.class otherClass:self throwException:YES];
|
||||
return [MVMCoreObject sharedInstance].sessionHandler;
|
||||
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].sessionHandler classToVerify:self];
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
|
||||
@ -26,4 +26,7 @@
|
||||
// returns if the class is not the same or a subclass of the other class. Can pass throw an exception as well
|
||||
+ (BOOL)classIsInstanceTypeOfClass:(Class)theClass otherClass:(Class)otherClass throwException:(BOOL)throwException;
|
||||
|
||||
// Calls the above function with throw exception yes if the object is not nil. Returns the object. Convenience function for one liner in initializer.
|
||||
+ (id)initializerClassCheck:(nullable NSObject *)object classToVerify:(Class)classToVerify;
|
||||
|
||||
@end
|
||||
|
||||
@ -147,4 +147,11 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (id)initializerClassCheck:(nullable NSObject *)object classToVerify:(Class)classToVerify {
|
||||
if (object) {
|
||||
[self classIsInstanceTypeOfClass:object.class otherClass:classToVerify throwException:YES];
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
@implementation MVMCoreViewControllerMappingObject
|
||||
|
||||
+ (nullable instancetype)sharedViewControllerMappingObject {
|
||||
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].viewControllerMapping.class otherClass:self throwException:YES];
|
||||
return [MVMCoreObject sharedInstance].viewControllerMapping;
|
||||
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].viewControllerMapping classToVerify:self];
|
||||
}
|
||||
|
||||
#pragma mark - View Controller Mapping
|
||||
|
||||
Loading…
Reference in New Issue
Block a user