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:

http://wwww.pastebin.com/1bm80ipp

where window's root view controller being set?

if in storyboard, ensure class of root view controller viewcontroller , not uitableviewcontroller.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -