BlueDolphin
BlueDolphin

Reputation: 9765

Which method when navigation bar "back" button clicked?

I am using UINavigationController to push and pop a view.

I used [[self navigationController] pushViewController:myView animated:YES] to push in a view. Then I clicked the top-left back button to go back, I am getting error:

*** -[NSCFDictionary superview]: unrecognized selector sent to instance 0x1451a0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary superview]: unrecognized selector sent to instance 0x1451a0'

I am wondering which method -popViewController is calling when the back button is called. Whether this error happens in the first view or the second view which is pushed in.

Thanks.

Upvotes: 0

Views: 3324

Answers (1)

Ben Gottlieb
Ben Gottlieb

Reputation: 85532

The Back button should be called -popViewControllerAnimated:. However, it sounds like you've got a class over-release bug here. Basically, you've got a view, which is being assigned somehwere. This view is just an address in memory. At some point, you're releasing this view all the way down to a retainCount of 0. When this happens, the view is dealloc'd. At some point after this, an NSDictionary is being created with the same memory address as your earlier, now deallocated, view. Now something is trying to send your view a message, but it's no longer there, instead, there's an NSDictionary there. It says something along the lines of: [view superview], but view is now pointing to a dictiinary, which doesn't respond to superview.

Bottom line: check your retain/release/autorelease calls, and make sure you're not over-releasing one of your views (or view controllers, though that's less likely).

Upvotes: 3

Related Questions