ios - Swift 2 arc4random_uniform crash? -
i have simple execution, it's crashing reason. ideas why?
import uikit class viewcontroller: uiviewcontroller { @iboutlet var mytextfield: uitextfield! @iboutlet var resultslabel: uilabel! @ibaction func pressbutton(sender: anyobject) { let diceroll = string(arc4random_uniform(uint32(6))) print(diceroll) } override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } crash log added
2016-02-06 16:24:32.358 guessinggame[6330:496415] * terminating app due uncaught exception 'nsunknownkeyexception', reason: '[ setvalue:forundefinedkey:]: class not key value coding-compliant key textfield.' * first throw call stack: ( 0 corefoundation 0x000000010960ae65 exceptionpreprocess + 165 1 libobjc.a.dylib 0x000000010b34adeb objc_exception_throw + 48 2 corefoundation 0x000000010960aaa9 -[nsexception raise] + 9 3 foundation 0x00000001099d39bb -[nsobject(nskeyvaluecoding) setvalue:forkey:] + 288 4 uikit 0x0000000109fb6320 -[uiviewcontroller setvalue:forkey:] + 88 5 uikit 0x000000010a1e4f41 -[uiruntimeoutletconnection connect] + 109 6 corefoundation 0x000000010954b4a0 -[nsarray makeobjectsperformselector:] + 224 7 uikit 0x000000010a1e3924 -[uinib instantiatewithowner:options:] + 1864 8 uikit 0x0000000109fbceea -[uiviewcontroller _loadviewfromnibnamed:bundle:] + 381 9 uikit 0x0000000109fbd816 -[uiviewcontroller loadview] + 178 10 uikit 0x0000000109fbdb74 -[uiviewcontroller loadviewifrequired] + 138 11 uikit 0x0000000109fbe2e7 -[uiviewcontroller view] + 27 12 uikit 0x0000000109e94ab0 -[uiwindow addrootviewcontrollerviewifpossible] + 61 13 uikit 0x0000000109e95199 -[uiwindow _sethidden:forced:] + 282 14 uikit 0x0000000109ea6c2e -[uiwindow makekeyandvisible] + 42 15 uikit 0x0000000109e1f663 -[uiapplication _callinitializationdelegatesformainscene:transitioncontext:] + 4131 16 uikit 0x0000000109e25cc6 -[uiapplication _runwithmainscene:transitioncontext:completion:] + 1760 17 uikit 0x0000000109e22e7b -[uiapplication workspacedidendtransaction:] + 188 18 frontboardservices 0x000000010d1df754 -[fbsserialqueue _performnext] + 192 19 frontboardservices 0x000000010d1dfac2 -[fbsserialqueue _performnextfromrunloopsource] + 45 20 corefoundation 0x0000000109536a31 __cfrunloop_is_calling_out_to_a_source0_perform_function + 17 21 corefoundation 0x000000010952c95c __cfrunloopdosources0 + 556 22 corefoundation 0x000000010952be13 __cfrunlooprun + 867 23 corefoundation 0x000000010952b828 cfrunlooprunspecific + 488 24 uikit 0x0000000109e227cd -[uiapplication _run] + 402 25 uikit 0x0000000109e27610 uiapplicationmain + 171 26 guessinggame 0x000000010942b4dd main + 109 27 libdyld.dylib 0x000000010be5392d start + 1 ) libc++abi.dylib: terminating uncaught exception of type nsexception (lldb)
most cause renamed iboutlet textfield mytextfield in code (or added new link did not remove old reference control in ib).
Comments
Post a Comment