remove duplicate function

Move back to delegate.
Throw error when using exact class, don't throw error when using protocol.
remove unused search path
This commit is contained in:
Pfeil, Scott Robert 2019-01-17 18:52:08 -05:00
parent feceef26df
commit 1429fd1fae
10 changed files with 21 additions and 22 deletions

View File

@ -946,11 +946,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/MVMCore/EmbeddedLibaries/AdobeMobileLibrary",
"$(PROJECT_DIR)/MVMCore/EmbeddedLibraries/VZAnalytics",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCore;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@ -975,11 +971,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/MVMCore/EmbeddedLibaries/AdobeMobileLibrary",
"$(PROJECT_DIR)/MVMCore/EmbeddedLibraries/VZAnalytics",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCore;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;

View File

@ -36,7 +36,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
@implementation MVMCoreActionHandler
+ (nullable instancetype)sharedActionHandler {
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].actionHandler.class otherClass:self];
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].actionHandler.class otherClass:self throwException:YES];
return [MVMCoreObject sharedInstance].actionHandler;
}

View File

@ -42,7 +42,7 @@
static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
+ (nullable instancetype)sharedCache {
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].cache.class otherClass:self];
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].cache.class otherClass:self throwException:YES];
return [MVMCoreObject sharedInstance].cache;
}

View File

@ -13,8 +13,11 @@
@implementation MVMCoreLoggingHandler
+ (nullable instancetype)sharedLoggingHandler {
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].loggingDelegate.class otherClass:self];
return [MVMCoreObject sharedInstance].loggingDelegate;
if ([MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].loggingDelegate.class otherClass:self throwException:NO]) {
return (MVMCoreLoggingHandler *)[MVMCoreObject sharedInstance].loggingDelegate;
} else {
return nil;
}
}
+ (void)addErrorToLog:(nonnull MVMCoreErrorObject *)errorObject {

View File

@ -13,7 +13,7 @@
@implementation MVMCoreSessionObject
+ (nullable instancetype)sharedGlobal {
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].session.class otherClass:self];
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].session.class otherClass:self throwException:YES];
return [MVMCoreObject sharedInstance].session;
}

View File

@ -47,7 +47,7 @@
@implementation MVMCoreSessionTimeHandler
+ (nullable instancetype)sharedSessionHandler {
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].sessionHandler.class otherClass:self];
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].sessionHandler.class otherClass:self throwException:YES];
return [MVMCoreObject sharedInstance].sessionHandler;
}

View File

@ -29,7 +29,7 @@
// The delegates
@property (nullable, weak, nonatomic) id <MVMCoreGlobalLoadProtocol> globalLoadDelegate;
@property (nullable, weak, nonatomic) id <MVMCoreLoadingOverlayDelegateProtocol> loadingProtocol;
@property (nullable, weak, nonatomic) MVMCoreLoggingHandler <MVMCoreLoggingDelegateProtocol> *loggingDelegate;
@property (nullable, weak, nonatomic) NSObject <MVMCoreLoggingDelegateProtocol> *loggingDelegate;
@property (nullable, weak, nonatomic) id <MVMCoreGlobalTopAlertDelegateProtocol> globalTopAlertDelegate;
// A reference to the calling application delegate that should be set. For a normal app, could be the UIApplicationDelegate. For watch, could be WKExtensionDelegate. For iMessage, could be MSMessagesAppViewController. etc, etc. Useful for the framework to call delegate specific functions.

View File

@ -23,7 +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;
// 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;
@end

View File

@ -137,10 +137,14 @@
[[MVMCoreNavigationHandler sharedNavigationHandler] navigateWithLoadObject:loadObject viewController:(viewControllerToLoad ?: viewController) delegate:delegate completionHandler:completionBlock];
}
+ (void)verifyClassIsInstanceTypeOfClass:(Class)theClass otherClass:(Class)otherClass {
+ (BOOL)classIsInstanceTypeOfClass:(Class)theClass otherClass:(Class)otherClass throwException:(BOOL)throwException {
if (theClass != otherClass && ![theClass isSubclassOfClass:otherClass]) {
@throw([NSException exceptionWithName:@"NotInstanceType" reason:[NSString stringWithFormat:@"%@ is not an instance of %@",theClass,otherClass] userInfo:nil]);
if (throwException) {
@throw([NSException exceptionWithName:@"NotInstanceType" reason:[NSString stringWithFormat:@"%@ is not an instance of %@",theClass,otherClass] userInfo:nil]);
}
return NO;
}
return YES;
}
@end

View File

@ -27,7 +27,7 @@
@implementation MVMCoreViewControllerMappingObject
+ (nullable instancetype)sharedViewControllerMappingObject {
[MVMCoreActionUtility verifyClassIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].viewControllerMapping.class otherClass:self];
[MVMCoreActionUtility classIsInstanceTypeOfClass:[MVMCoreObject sharedInstance].viewControllerMapping.class otherClass:self throwException:YES];
return [MVMCoreObject sharedInstance].viewControllerMapping;
}