ios - unrecognized selector sent to instance with UILabel in Swift -
i writing app in swift keeps track of baseball game. have on 20 labels need edit. keep getting "unrecognized selector sent instance" error. have set breakpoints on every uilabel outlet, , crashes after goes around second time on away2nd. here class app:
var home_scores = [int]() var away_scores = [int]() var player_list = [string]() var inning = 1 var topinning = true var strikes = 0 var balls = 0 var outs = 0 //outlets variable text @iboutlet var playerlist: uitableview! @iboutlet var strikestext: uilabel! @iboutlet var ballstext: uilabel! @iboutlet var outstext: uilabel! @iboutlet var inningtext: uilabel! @iboutlet var innsidetext: uilabel! @iboutlet var battername: uilabel! //outlets score text... lot of outlets //away @iboutlet var away1st: uilabel! @iboutlet var away2nd: uilabel! //crashes after breakpoint here @iboutlet var away3rd: uilabel! @iboutlet var away4th: uilabel! @iboutlet var away5th: uilabel! @iboutlet var away6th: uilabel! @iboutlet var away7th: uilabel! @iboutlet var away8th: uilabel! @iboutlet var away9th: uilabel! //home @iboutlet var home1st: uilabel! @iboutlet var home2nd: uilabel! @iboutlet var home3rd: uilabel! @iboutlet var home4th: uilabel! @iboutlet var home5th: uilabel! @iboutlet var home6th: uilabel! @iboutlet var home7th: uilabel! @iboutlet var home8th: uilabel! @iboutlet var home9th: uilabel! func displayscores() { away1st.text = string(away_scores[0]) away2nd.text = string(away_scores[1]) away3rd.text = string(away_scores[2]) away4th.text = string(away_scores[3]) away5th.text = string(away_scores[4]) away6th.text = string(away_scores[5]) away7th.text = string(away_scores[6]) away8th.text = string(away_scores[7]) away9th.text = string(away_scores[8]) home1st.text = string(home_scores[0]) home2nd.text = string(home_scores[1]) home3rd.text = string(home_scores[2]) home4th.text = string(home_scores[3]) home5th.text = string(home_scores[4]) home6th.text = string(home_scores[5]) home7th.text = string(home_scores[6]) home8th.text = string(home_scores[7]) home9th.text = string(home_scores[8]) } @ibaction func hitstrike() { strikes += 1 }
this error:
2016-11-10 14:00:30.463 base tracker ipad[5992:325296] -[uilabel longlongvalue]: unrecognized selector sent instance 0x7fcaf1601c90 process 5992 resuming 2016-11-10 14:00:30.538 base tracker ipad[5992:325296] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uilabel longlongvalue]: unrecognized selector sent instance 0x7fcaf1601c90' *** first throw call stack: ( 0 corefoundation 0x0000000105ab534b __exceptionpreprocess + 171 1 libobjc.a.dylib 0x0000000102dc921e objc_exception_throw + 48 2 corefoundation 0x0000000105b24f34 -[nsobject(nsobject) doesnotrecognizeselector:] + 132 3 corefoundation 0x0000000105a3ac15 ___forwarding___ + 1013 4 corefoundation 0x0000000105a3a798 _cf_forwarding_prep_0 + 120 5 foundation 0x0000000102953faf _nssetlonglongvalueforkeywithmethod + 63 6 foundation 0x00000001028d926f -[nsobject(nskeyvaluecoding) setvalue:forkey:] + 291 7 uikit 0x00000001034324ef -[uiviewcontroller setvalue:forkey:] + 88 8 uikit 0x00000001036a679e -[uiruntimeoutletconnection connect] + 109 9 corefoundation 0x0000000105a5a590 -[nsarray makeobjectsperformselector:] + 256 10 uikit 0x00000001036a5122 -[uinib instantiatewithowner:options:] + 1867 11 uikit 0x0000000103438c21 -[uiviewcontroller _loadviewfromnibnamed:bundle:] + 386 12 uikit 0x0000000103439543 -[uiviewcontroller loadview] + 177 13 uikit 0x0000000103439878 -[uiviewcontroller loadviewifrequired] + 201 14 uikit 0x000000010343a0cc -[uiviewcontroller view] + 27 15 uikit 0x0000000103acd4be -[uipageviewcontroller _setviewcontrollers:withscrollindirection:animated:completion:] + 591 16 uikit 0x0000000103acd744 -[uipageviewcontroller setviewcontrollers:direction:animated:completion:] + 269 17 base tracker ipad 0x00000001027d0531 _tfc17base_tracker_ipad20mypageviewcontroller11viewdidloadft_t_ + 2609 18 base tracker ipad 0x00000001027d07f2 _ttofc17base_tracker_ipad20mypageviewcontroller11viewdidloadft_t_ + 34 19 uikit 0x0000000103439c99 -[uiviewcontroller loadviewifrequired] + 1258 20 uikit 0x000000010343a0cc -[uiviewcontroller view] + 27 21 uikit 0x0000000103d04bce __67-[uistoryboardembedseguetemplate newdefaultperformhandlerforsegue:]_block_invoke + 496 22 uikit 0x0000000103a72fbd -[uistoryboardseguetemplate _performwithdestinationviewcontroller:sender:] + 447 23 uikit 0x0000000103a72dcd -[uistoryboardseguetemplate _perform:] + 82 24 uikit 0x0000000103a7308f -[uistoryboardseguetemplate perform:] + 156 25 uikit 0x0000000103439a7e -[uiviewcontroller loadviewifrequired] + 719 26 uikit 0x000000010343a0cc -[uiviewcontroller view] + 27 27 uikit 0x0000000103303c51 -[uiwindow addrootviewcontrollerviewifpossible] + 71 28 uikit 0x00000001033043a2 -[uiwindow _sethidden:forced:] + 293 29 uikit 0x0000000103317cb5 -[uiwindow makekeyandvisible] + 42 30 uikit 0x0000000103290c89 -[uiapplication _callinitializationdelegatesformainscene:transitioncontext:] + 4818 31 uikit 0x0000000103296de9 -[uiapplication _runwithmainscene:transitioncontext:completion:] + 1731 32 uikit 0x0000000103293f69 -[uiapplication workspacedidendtransaction:] + 188 33 frontboardservices 0x0000000107179723 __fbsserialqueue_is_calling_out_to_a_block__ + 24 34 frontboardservices 0x000000010717959c -[fbsserialqueue _performnext] + 189 35 frontboardservices 0x0000000107179925 -[fbsserialqueue _performnextfromrunloopsource] + 45 36 corefoundation 0x0000000105a5a311 __cfrunloop_is_calling_out_to_a_source0_perform_function__ + 17 37 corefoundation 0x0000000105a3f59c __cfrunloopdosources0 + 556 38 corefoundation 0x0000000105a3ea86 __cfrunlooprun + 918 39 corefoundation 0x0000000105a3e494 cfrunlooprunspecific + 420 40 uikit 0x00000001032927e6 -[uiapplication _run] + 434 41 uikit 0x0000000103298964 uiapplicationmain + 159 42 base tracker ipad 0x00000001027d79bf main + 111 43 libdyld.dylib 0x00000001069e268d start + 1 ) libc++abi.dylib: terminating uncaught exception of type nsexception
what causing error? have seen can caused reused memory, when app loading.
this can happen if 1 of label in storyboard/nib file connected in view controller , later on variable in view controller corresponding label's connection removed. leave dangling reference label in storyboard/nib file.
i check each every ui elements in storyboard/nib file , see if there variable names not have referenced inside corresponding view controller.
Comments
Post a Comment