ios - random crash on pickerview didSelect : __cfrunloop_is_calling_out_to_a_source1_perform1_function -


i have received following crash report not understand issue.line 487 points check if pickerview in delegate particular variable.

crashed: com.apple.main-thread 0  app                    0x1001c5208 specialized newcorrectivevc.pickerview(uipickerview, didselectrow : int, incomponent : int) -> () (newcorrectivevc.swift:487) 1  app                    0x1001c2028 @objc newcorrectivevc.pickerview(uipickerview, didselectrow : int, incomponent : int) -> () (newcorrectivevc.swift) 2  uikit                  0x197a83154 -[uipickerview _sendselectionchangedforcomponent:notify:] + 116 3  uikit                  0x197a8338c -[uipickerview _sendselectionchangedfromtable:notify:] + 344 4  uikit                  0x197fb0424 -[uipickertableview _scrollingfinished] + 188 5  uikit                  0x197fb05fc -[uipickertableview scrollviewdidenddecelerating:] + 28 6  uikit                  0x197b216ac -[uiscrollview(uiscrollviewinternal) _scrollviewdidenddeceleratingfordelegate] + 132 7  uikit                  0x1979b6db0 -[uiscrollview(uiscrollviewinternal) _stopscrolldecelerationnotify:] + 332 8  uikit                  0x1979b68ec -[uiscrollview _smoothscrollwithupdatetime:] + 2356 9  quartzcore             0x194bc01bc ca::display::displaylinkitem::dispatch(unsigned long long) + 44 10 quartzcore             0x194bc0068 ca::display::displaylink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 444 11 iokit                  0x191c27138 iodispatchcalloutfromcfmessage + 372 12 corefoundation         0x19195056c __cfmachportperform + 180 13 corefoundation         0x191968934 __cfrunloop_is_calling_out_to_a_source1_perform_function__ + 56 14 corefoundation         0x1919680e8 __cfrunloopdosource1 + 436 15 corefoundation         0x191965bcc __cfrunlooprun + 1840 16 corefoundation         0x191894048 cfrunlooprunspecific + 444 17 graphicsservices       0x19331a198 gseventrunmodal + 180 18 uikit                  0x1978792fc -[uiapplication _run] + 684 19 uikit                  0x197874034 uiapplicationmain + 208 20 app                    0x100173d04 main (appdelegate.swift:22) 21 libdispatch.dylib      0x1908785b8 (missing) 

code:

func pickerview(_ pickerview: uipickerview, didselectrow row: int, incomponent component: int) {     if pickerview == assignedto     {         if employees.count > 0 {             selectedemp =  employees[row].employeeid         }     }     else if pickerview == category \\this line 487     {         if categories.count > 0 {             selectedcat = categories[row].wocategoryid         }     } } 

edit:

not sure if following relevant have observers linked pickerviews:

let longpressrecognizer = uilongpressgesturerecognizer(target: self, action: #selector(self.longpressed)) assignedto.addgesturerecognizer(longpressrecognizer) let catlongpressrecognizer = uilongpressgesturerecognizer(target: self, action: #selector(self.catlongpressed)) category.addgesturerecognizer(catlongpressrecognizer) self.hidekeyboardwhentappedaround() self.scroll.keyboarddismissmode = .interactive 

fyi:

public func hidekeyboardwhentappedaround() {     let tap: uitapgesturerecognizer = uitapgesturerecognizer(target: self, action: #selector(uiviewcontroller.dismisskeyboard))     view.addgesturerecognizer(tap) } 

i suspect problem in call ==.

if pickerview == assignedto 

this isn't mean. forces call == function , tries evaluate equality between these 2 objects. if 1 of them nil crash.

pickerview should never nil, i've encountered cases uikit sends nil parameters should never nil. (this can happen if there calls uikit methods on background threads. careful not doing that, can happen due uikit bugs.)

assignedto can nil if view hasn't loaded. in theory should never call in case, again, it's possible in presence of bugs, again commonly due calling uikit methods off main thread (any uikit methods; doesn't have related particular picker view), uikit has bugs of own.

in case, don't mean "is pickerview equal assignedto." mean "is pickerview exactly same thing assignedto." that's ===:

if pickerview === assignedto 

=== pointer comparison, in face of invalid nil it's safe.

keep in mind related race condition. fact doesn't reproduce when run in debugger doesn't mean anything. might happen once in 10k tries, in release, exclusively on iphone 6. that's nature of race conditions.


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 -