tags:

views:

2033

answers:

3

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.

+2  A: 

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).

Ben Gottlieb
+1  A: 

Per Ben's suggestion, I rechecked the code, it appears that I have a local UIButton, which was created and released in the method. After I changed that local variable UIButton to instance variable and only release in dealloc, issue appears gone.

Thanks Ben

BlueDolphin
A: 

thank you Ben for above information, i got same problem in imageviews, i checked code, only imageviews then i found my mistake.....

dazz