You could use the UINavigationController
‘s viewControllers
property:
@property(nonatomic, copy) NSArray *viewControllers
Discussion: The root view controller is at index 0 in the array, the back view controller is at index n-2, and the top controller is at index n-1, where n is the number of items in the array.
https://developer.apple.com/documentation/uikit/uinavigationcontroller
You could use that to test whether the root view controller (the one at array index 0) is view controller A or B.