MMMNavigationStack
Objective-C
@interface MMMNavigationStack : NSObject
Swift
class MMMNavigationStack : NSObject
This is to track the navigation state of the app and have the possibility to programmatically return to registered points of the navigation path. The actual navigation entities of the app (usually view controllers) must cooperate in order to achieve this.
The possibility to go back is needed to properly handle in-app links. We have a basic mechanism for this (MMMNavigation) which allows to “open” a part of a link and forward the remaining parts to the corresponding handler down the navigation tree. The handlers thus need to be able to “close” current navigation path before opening something new.
Although navigation in the app is better represented by a tree, we assume here that at least the current path in this tree can be represented as a stack. Each element of the stack can correspond to a modal view controller or alert view, for example, but it can also correspond to a special state of the app or a screen.
-
Undocumented
Declaration
Objective-C
+ (instancetype)shared;
Swift
class func shared() -> Self
-
Notifies the stack about a new modal navigation context facing the user now, such as a modal view controller being presented or any other special state of the UI which would require either the assistance from the user or navigation items’ delegate in order to return to the previous navigation step.
Again, navigation steps are not limited to modal view controllers, there can be any entity responsible for the current state of the UI which wants to clean it up properly when asked for via the corresponding delegate.
The optional
controller
parameter might be a view controller corresponding to the new navigation item. This can be used by this controller withpopAllAfterController:completion:
method in order to cancel/pop all the navigation items added after it.A nil is returned if it’s not possible to push anything now (because the stack is in the middle of a change).
For now trying to push something when “popping” is in progress is considered a programmer’s error however and it will crash in Debug.
Declaration
Objective-C
- (nullable id<MMMNavigationStackItem>) pushItemWithName:(nonnull NSString *)name delegate:(nonnull id<MMMNavigationStackItemDelegate>)delegate controller:(nullable id)controller;
Swift
func pushItem(name: String, delegate: any MMMNavigationStackItemDelegate, controller: Any?) -> (any MMMNavigationStackItem)?
-
Undocumented
Declaration
Objective-C
- (BOOL)popAllAfterController:(id)controller completion:(MMMNavigationStackCompletion)completion;
Swift
func popAll(afterController controller: Any, completion: @escaping MMMNavigationStackCompletion) -> Bool