IOS app crashes with cfrunloop_is_calling_out_to_an_observer_callback_function

When I run my application, I sometimes get this crash, which seems to have nothing with my code. What is it and how do I prevent it?

Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Fail 0 libsystem_kernel.dylib 0x000000018fc4c16c mach_msg_trap + 1 August libsystem_kernel.dylib
  0x000000018fc4bfdc mach_msg + 72 2 AudioToolbox
  0x0000000193c8bcdc ASClient_AudioSessionSetActiveWithFlags + 132 3
AudioToolbox 0x0000000193c6c7f4 AudioSessionSetActive_Priv + 360 4 AVFAudio
  0x00000001aa46bf8c - [AVAudioSession setActive: withOptions: error:] + 84 5 Trial session 0x00000001000d41b8 0x1000b0000 + 147896 6 jam sessions 0x00000001000d53fc 0x1000b0000 + 152572 7 UIKit
  0x0000000196ae90ec - [UIViewController loadViewIf56 + 8View56
UIKit 0x0000000196ba2cdc - [UINavigationController _layoutViewController:] + 72 9 UIKit 0x0000000196ba2bb4 - [UINavigationController _updateScrollViewFromViewController: toViewController :] + 416 10 UIKit 0x0000000196ba1efc - [UINavigationController _startTransition: fromViewController : toViewController:] + 140 11 UIKit 0x0000000196ba1948 - [UINavigationController _startDeferredTransitionIfNeeded:] + 856 12 UIKit 0x0000000196ba14fc - [UINavigationController viewWillLayoutSubviews] + 64 13 UIKit 0x0000000196ba1460 - [UILayoutContainerView layoutSubviews] + 188 14 UIKit 0x0000000196ae625c - + UIViewCallet8Leoercloverfloaderfilecluerfloor1101cuetlayer8148018a8c0114a018a8c14a01
  0x0000000193fa1fa4 CA :: Layer :: layout_if_needed (CA :: Transaction *) + 292 17 QuartzCore 0x0000000193fa1e64 CA :: Layer :: layout_and_display_if_needed (CA :: Transaction *) + 32 18 QuartzCore 0x0000000193f1eb20 CA :: Context :: commit_transaction Transaction *) + 252 19 QuartzCore 0x0000000193f45f8c CA :: Transaction :: commit ( ) + 20 512 QuartzCore
  0x0000000193f469ac CA Transaction :: :: observer_callback (CFRunLoopObserver __ *, unsigned long, void *) + 120 21 CoreFoundation
  0x0000000190c4a7dc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 32 22 CoreFoundation 0x0000000190c4840c __CFRunLoopDoObservers + 372 23 CoreFoundation 0x0000000190b77068 CFRunLoopRunSpecific + 476 24 UIKit
  0x0000000196b542ec - [UIApplication _run] + 608 25 UIKit
  0x0000000196b4f070 UIApplicationMain + 208 26 Jam Session
  0x0000000101c36d4 0x1000b0000 + 79572 27 libdyld.dylib
  0x000000018fb585b8 start + 4

+4
source share
2 answers

This error occurs when using NSNotificationCenter

You registered an observer notification for an object that was released and did not delete the observer. Therefore, when he tries to call the selector, it will work.

If you use any ViewController, you can add

[[NSNotificationCenter defaultCenter] removeObserver:self name:@"Notification" object:nil];

at viewWillDisappear

if it is not a ViewController, you can use -(void) deallocObserver to unregister.

, . , , .

.

!

0

UIView, , :

-, " " "".. , IBInspectable StoryBoard, , , .

" ".

0

Source: https://habr.com/ru/post/1657841/


All Articles