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 }
1.4m articles
1.4m replys
5 comments
57.0k users