0

I'm getting the following runtime error and I cannot determine for the life of me WHYYYY. The error is Thread 1: EXC_BREAKPOINT (code=EXC_1386_BPT, subcode=0x0) which seems to happen whenever I execute the dismissModalViewController:animated or the pushViewController:animated method from any of my VC's.

I have enabled zombie objects and that shows me the following message in the debugger, 2012-06-14 16:34:58.769 MyApp[5952:17903] *** -[MyDetailsVC respondsToSelector:]: message sent to deallocated instance 0x8c3d400.

This ONLY happens after I access the MyDetailsVC ViewController. The scenario is as follows.

  • start the app, everything works perfectly, I can push to and pop from view controllers and present and dismiss modal VC's without any issues.
  • I push to the MyDetailsVC, do nothing on it, then tap the back button.
  • I'm now back to where I was before pushing to the MyDetailsVC, the app continues to work perfectly until I reach a point where I have to push to a VC or present a modal VC. I then get the runtime error.

The MyDetailsVC is not even in the picture nor does it have anything to do with the other VC's when I encounter the error.

How can I get more granular with the debugger in order to determine what this issue is?

Also, the error message says the words "message sent", so I've pretty much commented all of my NSNotifications in my VC's to rule out the chance that one of my VC's is trying to send a message to a VC that is no longer alive... no luck!

PS - I'm using Xcode 4.3.1, 5.1 w/ ARC

ElasticThoughts
  • 3,417
  • 8
  • 43
  • 58

2 Answers2

1

The issue is not NSNotifications. Messages in objective-c are just function/method calls. It looks like respondsToSelector: is causing the issue.

Check if MyDetailsVC has [self respondsToSelector:@"some method here"]. Also it could be that another objects calls respondsToSelector on MyDetailsVC after MyDetailsVC was dismissed and deallocated. Make sure in MyDetailsVC under viewDidUnload you set @synthesized properties to nil and stopped all pending performSelector calls.

Alex L
  • 8,419
  • 6
  • 43
  • 51
  • I did a search for anything in MyDetailsVC that uses `@selector`, everything that I've found (6) methods in total are all piddly methods that are used solely in the MyDetailsVC. For example, selectors on buttons that perform small tasks, present actionSheets, etc... Also, in my ViewDidLoad method I have an NSLog message on the first line to see if the ViewDidLoad ever even gets called and it never does so I don't even know how the MyDetailsVC could even be deallocated... Is it possible that this is a bogus message from the debugger? – ElasticThoughts Jun 15 '12 at 00:38
1

Nothing in callback stack in debugger to show you which line of your code is happening?

respondsToSelector is called a lot on delegates (to see if an optional method in a protocol is implemented). Did your MyDetailsVC assign itself as a delegate to anything? If so, be sure and assign xyz.delegate = nil in your dealloc routine.

So you probably have "self.navigationController.delegate = self". So, you need a matching "self.navigationController.delegate = nil" in your dealloc routine.

mackworth
  • 5,873
  • 2
  • 29
  • 49
  • No, I don't assign it a delegate to anything however I do use the following protocols in it. (``). In the callback stack in the debugger it always points to the line of code that reads `[self dismissModalViewControllerAnimated:YES];` in any VC that uses that method, and it does the same for `[self.navigationController pushViewController:someOtherVC animated:YES];` – ElasticThoughts Jun 15 '12 at 00:34
  • 1
    So, you are assigned as a delegate to all of those things, no? (e.g. self.tableview.delegate = self ) All of them need to be nil'ed out during your dealloc (although your tableview itself should be dealloced then. Personally, I'd look at the UINavController delegate, as your myDetailsVC would be notified by your modal/push calls. – mackworth Jun 15 '12 at 00:39
  • Holy $$$ that fregging `[self.navigationController setDelegate:self];` was the issue! I removed the protocol from the header and commented out the setDelegate:self line and viola it worked!. Thank you so much for your help!! Please submit your comment as an answer and I'll mark it as accepted. – ElasticThoughts Jun 15 '12 at 00:57
  • So where do I put the `setDelegate:nil` call? My viewDidUnload only gets called when the app receives a memory warning and the VC is not in view. do I put it in `- (void)dealloc { [self.navigationController setDelegate:nil]; }`? I tried that but it does not fix the problem. – ElasticThoughts Jun 15 '12 at 01:09
  • That's where it should go (although I viewDidUnload should also work; pretty sure that's called before a dealloc of a VC). I don't know why you need the callback, but if it's only when you're on the screen, then you could set it to nil in viewDidDisappear. – mackworth Jun 15 '12 at 02:59