1

I use a property (the name is 'userInteractionEnabled') to change navigationController.navigationBar's state , but Xcode throw Error ,

Please look this image : enter image description here

your can see this code , when the App invoke [self viewDidDisappear:] method that Xcode throw Error . Error message : EXC_BAD_ACCESS(code=2,address=0x7fff5bc8bfb8)

Can your please me? why Xcode throw error ? why throw EXC_BAD_ACCESS ? Why ?

user5465320
  • 719
  • 2
  • 7
  • 15
  • This might help you http://stackoverflow.com/questions/9116557/when-should-i-call-removeobserverforkeypath-from-within-a-closing-viewcontrolle – Ali Baqbani Sep 17 '16 at 04:12

1 Answers1

2

You have a recursion problem. You are modifying the observed property at the time you are handling the observation of the previous change to the property.

Look at the stack trace. It's stuck calling the observer over and over as each observation changes the property again.

Don't change an observed property directly in the observeValueForKeyPath method.

rmaddy
  • 314,917
  • 42
  • 532
  • 579