swift - crash in cellForRow : __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION -


i have following crash report in cellforrow method.

this not can reproduce myself when running through xcode.

crashed: com.apple.main-thread 0  app                            0x1004a7624 specialized inspectionitemvc.tableview(uitableview, cellforrowat : indexpath) -> uitableviewcell (inspectionitemvc.swift:610) 1  app                           0x10049f82c @objc inspectionitemvc.tableview(uitableview, cellforrowat : indexpath) -> uitableviewcell (inspectionitemvc.swift) 2  uikit                          0x198931d90 -[uitableview _createpreparedcellforglobalrow:withindexpath:willdisplay:] + 688 3  uikit                          0x198931fa8 -[uitableview _createpreparedcellforglobalrow:willdisplay:] + 80 4  uikit                          0x19891f6ac -[uitableview _updatevisiblecellsnow:isrecursive:] + 2152 5  uikit                          0x198936f98 -[uitableview _performwithcachedtraitcollection:] + 120 6  uikit                          0x1986cf49c -[uitableview layoutsubviews] + 176 7  uikit                          0x1985e9cc0 -[uiview(calayerdelegate) layoutsublayersoflayer:] + 1200 8  quartzcore                     0x1957da274 -[calayer layoutsublayers] + 148 9  quartzcore                     0x1957cede8 ca::layer::layout_if_needed(ca::transaction*) + 292 10 uikit                          0x1985fe458 -[uiview(hierarchy) layoutbelowifneeded] + 548 11 uikit                          0x1986a50c8 -[uinavigationcontroller _layoutviewcontroller:] + 1244 12 uikit                          0x1986a2944 -[uinavigationcontroller _layouttopviewcontroller] + 228 13 uikit                          0x1986bb6f4 -[uinavigationcontroller navigationtransitionview:didendtransition:fromview:toview:] + 744 14 uikit                          0x1986bb3d0 -[uinavigationtransitionview _notifydelegatetransitiondidstopwithcontext:] + 420 15 uikit                          0x1986bafa0 -[uinavigationtransitionview _cleanuptransition] + 608 16 uikit                          0x198625060 -[uiviewanimationstate senddelegateanimationdidstop:finished:] + 312 17 uikit                          0x19862320c +[uiviewanimationstate popanimationstate] + 320 18 uikit                          0x1986ae7dc -[uinavigationtransitionview transition:fromview:toview:] + 1860 19 uikit                          0x1986a4764 -[uinavigationcontroller _starttransition:fromviewcontroller:toviewcontroller:] + 2488 20 uikit                          0x1986a3870 -[uinavigationcontroller _startdeferredtransitionifneeded:] + 856 21 uikit                          0x1986a3424 -[uinavigationcontroller __viewwilllayoutsubviews] + 64 22 uikit                          0x1986a3388 -[uilayoutcontainerview layoutsubviews] + 188 23 uikit                          0x1985e9cc0 -[uiview(calayerdelegate) layoutsublayersoflayer:] + 1200 24 quartzcore                     0x1957da274 -[calayer layoutsublayers] + 148 25 quartzcore                     0x1957cede8 ca::layer::layout_if_needed(ca::transaction*) + 292 26 quartzcore                     0x1957ceca8 ca::layer::layout_and_display_if_needed(ca::transaction*) + 32 27 quartzcore                     0x19574a34c ca::context::commit_transaction(ca::transaction*) + 252 28 quartzcore                     0x1957713ac ca::transaction::commit() + 504 29 uikit                          0x1985df308 _aftercacommithandler + 256 30 corefoundation                 0x1924689a8 __cfrunloop_is_calling_out_to_an_observer_callback_function__ + 32 31 corefoundation                 0x192466630 __cfrunloopdoobservers + 372 32 corefoundation                 0x192466a7c __cfrunlooprun + 956 33 corefoundation                 0x192396da4 cfrunlooprunspecific + 424 34 graphicsservices               0x193e01074 gseventrunmodal + 100 35 uikit                          0x198651c9c uiapplicationmain + 208 36 app                            0x1000cfd04 main (appdelegate.swift:22) 37 libdyld.dylib                  0x1913a559c start + 4 

i read error in question linked nsnotificationcenter , need remove observer in viewwilldisappear.

i had removed observer in deinit , viewdiddisappear. if add removal of observer viewwilldisappear also, should solve issue?

also if add observer removal viewwilldisappear, should rid of code in deinit , viewdiddisappear?

previous code:

override func viewdidappear(_ animated: bool) {     super.viewdidappear(animated)     notificationcenter.default.addobserver(self, selector:#selector(checktimeout), name: nsnotification.name(rawvalue: "appopened"), object: nil) }  deinit {     notificationcenter.default.removeobserver(self) }  override func viewdiddisappear(_ animated: bool) {     super.viewdiddisappear(animated);     notificationcenter.default.removeobserver(self) }  override func viewwilldisappear(_ animated: bool) {     //should add notificationcenter.default.removeobserver(self) here , remove other 2 places above?     if let answers = helper_eqi_answer.getanswers(inspectionid)     {         inspection?.answers = answers;     } } 

cellforrow snippet: included case of switch statement points line 610. eqi_question type enum. cases satisfied in switch

func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell     {         if let item: = insp_questions?[indexpath.row]{              if 1...12 ~= item.type && answerids != nil             {                 switch (eqi_questiontype(rawvalue: item.type)!)                 {                 case .true_false:                     if let cell = tableview.dequeuereusablecell(withidentifier: "iq_flipcell") as? iq_flipcell                     {                         cell.table = questiontable;                         cell.delegate = self;                         cell.qid = answerids![indexpath.row];                         cell.selectionstyle = .none                         //this empty line 610                         if questionna[indexpath.row]                         {                             cell.nabox.setimage(#imageliteral(resourcename: "checkbox_selected"), for: .normal);                             cell.questionitem.ishidden = true;                         } else {                             cell.nabox.setimage(#imageliteral(resourcename: "checkbox_up"), for: .normal);                             cell.questionitem.ishidden = false;                         }                          let cell2 = cell.formatcell(with: item, for: cell, at: indexpath, qtype: 0)                         textheight[indexpath.row] = cell.questiontext.numberofvisiblelines;                         if item.question.characters.count > 40                         {                             textheight[indexpath.row] += 1                         }                         return cell2;                     }                 }             }          }     return uitableviewcell(); } 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -