As far as I know, this would work in Objective-C:
self.window.rootViewController.class == myViewController
How can I check if the current view controller is a specific one?
To check the class in Swift, use "is" (as explained under "checking Type" in the chapter called Type Casting in the Swift Programming Guide)
if self.window.rootViewController is MyViewController { //do something if it's an instance of that class }
2.1m questions
2.1m answers
60 comments
57.0k users