diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 6845002..f1d48bc 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -123,6 +123,8 @@ AFBB96ED1FBA4A260008D868 /* MFHardCodedServerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */; }; AFC5FA161FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFC5FA1D1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFC5FA1C1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AFEA17A8209B6A1C00BC6740 /* MVMCoreBlockOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFEA17A6209B6A1C00BC6740 /* MVMCoreBlockOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AFEA17A9209B6A1C00BC6740 /* MVMCoreBlockOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFEA17A7209B6A1C00BC6740 /* MVMCoreBlockOperation.m */; }; AFED77A11FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFED77991FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFED77A21FCCA29400BAE689 /* MVMCoreViewControllerMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFED779A1FCCA29300BAE689 /* MVMCoreViewControllerMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AFED779B1FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.m */; }; @@ -251,6 +253,8 @@ AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFHardCodedServerResponse.m; sourceTree = ""; }; AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreGlobalTopAlertDelegateProtocol.h; sourceTree = ""; }; AFC5FA1C1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertViewProtocol.h; sourceTree = ""; }; + AFEA17A6209B6A1C00BC6740 /* MVMCoreBlockOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreBlockOperation.h; sourceTree = ""; }; + AFEA17A7209B6A1C00BC6740 /* MVMCoreBlockOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreBlockOperation.m; sourceTree = ""; }; AFED77991FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerNibMappingObject.h; sourceTree = ""; }; AFED779A1FCCA29300BAE689 /* MVMCoreViewControllerMappingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerMappingObject.h; sourceTree = ""; }; AFED779B1FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreViewControllerNibMappingObject.m; sourceTree = ""; }; @@ -327,6 +331,8 @@ 881D268F1FCC9D180079C521 /* MVMCoreErrorObject.m */, 881D26921FCC9D180079C521 /* MVMCoreOperation.h */, 881D26901FCC9D180079C521 /* MVMCoreOperation.m */, + AFEA17A6209B6A1C00BC6740 /* MVMCoreBlockOperation.h */, + AFEA17A7209B6A1C00BC6740 /* MVMCoreBlockOperation.m */, AFBB96E71FBA4A260008D868 /* HardCodedServerResponse */, AFBB96AB1FBA3B590008D868 /* Helpers */, ); @@ -647,6 +653,7 @@ AFBB968B1FBA3A9A0008D868 /* MVMCoreDismissViewControllerOperation.h in Headers */, AF43A70B1FC4F415008E9347 /* MVMCoreCache.h in Headers */, AFBB965C1FBA3A570008D868 /* MFFreebeeHandler.h in Headers */, + AFEA17A8209B6A1C00BC6740 /* MVMCoreBlockOperation.h in Headers */, AF43A5831FBB66DE008E9347 /* MVMCoreConstants.h in Headers */, AFBB969A1FBA3A9A0008D868 /* MVMCoreAlertDelegateProtocol.h in Headers */, AFED77A81FCCA29400BAE689 /* MVMCoreViewControllerStoryBoardMappingObject.h in Headers */, @@ -795,6 +802,7 @@ AF43A7071FC4D7A2008E9347 /* MVMCoreObject.m in Sources */, AFBB96B11FBA3B590008D868 /* MVMCoreDispatchUtility.m in Sources */, AFBB965B1FBA3A570008D868 /* FreeBeeUrlObject.m in Sources */, + AFEA17A9209B6A1C00BC6740 /* MVMCoreBlockOperation.m in Sources */, AF43A70A1FC4F415008E9347 /* MVMCoreCache.m in Sources */, AF43A6FF1FBE3252008E9347 /* Reachability.m in Sources */, AFBB96921FBA3A9A0008D868 /* MVMCoreNavigationOperation.m in Sources */, diff --git a/MVMCore/MVMCore/MVMCore.h b/MVMCore/MVMCore/MVMCore.h index 923a1bc..e3402cf 100644 --- a/MVMCore/MVMCore/MVMCore.h +++ b/MVMCore/MVMCore/MVMCore.h @@ -35,6 +35,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; #import #import #import +#import // Mapping #import diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.h b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.h index a3e5bcd..32789d0 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.h +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.h @@ -10,6 +10,7 @@ #import #import +@class MVMCoreOperation; @class MVMCoreNavigationObject; @class MVMCoreLoadObject; @@ -67,6 +68,9 @@ // Use this to pop to the root of the stack. - (void)popToRootAnimated:(BOOL)animated; +// Adds the navigation operation to the queue. +- (void)addNavigationOperation:(nonnull MVMCoreOperation *)operation; + // Removes all queued up items. - (void)cancelNavigation; diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m index 727d97b..4f89c71 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m @@ -165,7 +165,12 @@ - (void)popToRootAnimated:(BOOL)animated { MVMCoreNavigationObject *navigationObject = [[MVMCoreNavigationObject alloc] initWithViewController:nil navigationController:nil viewControllers:nil animated:animated tryToReplaceFirst:NO navigationType:NavigationTypePopToRoot]; - [self startNavigationWithNavigationObject:navigationObject delegate:nil completionHandler:NULL];} + [self startNavigationWithNavigationObject:navigationObject delegate:nil completionHandler:NULL]; +} + +- (void)addNavigationOperation:(nonnull MVMCoreOperation *)operation { + [self.navigationQueue addOperation:operation]; +} - (void)cancelNavigation { [self.navigationQueue cancelAllOperations]; diff --git a/MVMCore/MVMCore/Utility/MVMCoreBlockOperation.h b/MVMCore/MVMCore/Utility/MVMCoreBlockOperation.h new file mode 100644 index 0000000..5096a20 --- /dev/null +++ b/MVMCore/MVMCore/Utility/MVMCoreBlockOperation.h @@ -0,0 +1,16 @@ +// +// MVMCoreBlockOperation.h +// MVMCore +// +// Created by Pfeil, Scott Robert on 5/3/18. +// Copyright © 2018 myverizon. All rights reserved. +// + +#import + +@interface MVMCoreBlockOperation : MVMCoreOperation + +// Start this operation with the block. This block needs to call mark as finished when finished. ++ (nullable instancetype)blockOperationWithBlock:(nonnull void (^)(MVMCoreBlockOperation * _Nonnull operation))block; + +@end diff --git a/MVMCore/MVMCore/Utility/MVMCoreBlockOperation.m b/MVMCore/MVMCore/Utility/MVMCoreBlockOperation.m new file mode 100644 index 0000000..85a223a --- /dev/null +++ b/MVMCore/MVMCore/Utility/MVMCoreBlockOperation.m @@ -0,0 +1,37 @@ +// +// MVMCoreBlockOperation.m +// MVMCore +// +// Created by Pfeil, Scott Robert on 5/3/18. +// Copyright © 2018 myverizon. All rights reserved. +// + +#import "MVMCoreBlockOperation.h" + +@interface MVMCoreBlockOperation () + +@property (nonatomic, copy) void (^block)(MVMCoreBlockOperation * _Nonnull operation); + +@end + +@implementation MVMCoreBlockOperation + ++ (nullable instancetype)blockOperationWithBlock:(nonnull void (^)(MVMCoreBlockOperation * _Nonnull operation))block { + MVMCoreBlockOperation *operation = [[MVMCoreBlockOperation alloc] init]; + operation.block = block; + return operation; +} + + +- (void)main { + + // Always check for cancellation before launching the task. + if ([self checkAndHandleForCancellation]) { + return; + } + + __weak typeof(self) weakSelf = self; + self.block(weakSelf); +} + +@end