I am trying to cast my window.rootViewController as a UIPageViewController but anytime I access the class property which I defined it blows up with swift dynamic cast failed
. My storyboard has a UIPageViewController is the initial scene.
PageViewController is just a subclass of UIPageViewController
class AppDelegate: UIResponder, UIApplicationDelegate, UIPageViewControllerDataSource {
var window: UIWindow!
var pageViewController: PageViewController {
return window.rootViewController as PageViewController
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
pageViewController.dataSource = self
return true
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…