iOS (Swift) - Casting root view controller of the app delegate's window works in simulator, but fails when app is loaded on phone -
when run app following lines of code (inside appdelegate.swift file):
func locationmanager(manager: cllocationmanager!, didrangebeacons beacons: [anyobject], inregion region: clbeaconregion!) { let viewcontroller:viewcontroller = window!.rootviewcontroller as! viewcontroller viewcontroller.beacons = beacons as! [clbeacon] viewcontroller.tableview.reloaddata() ...... }
it runs flawlessly when run app in simulator. otherwise, when run app on phone runtime error:
could not cast value of type 'uitableviewcontroller' (0x198be57d0) 'beacontest.viewcontroller' (0x1000e15d0).
viewcontroller subclass of uitableviewcontroller defined so:
where window's root view controller being set?
if in storyboard, ensure class of root view controller viewcontroller
, not uitableviewcontroller
.
Comments
Post a Comment