0

I'm getting a strange exception in Xcode 4.2.1 (ARC-enabled project) that I can't track down to the root of the problem.

This is what the exception looks like:

2012-03-18 22:19:32.855 Project[14225:707] +[UIPickerTableViewTitledCell isEqualToString:]: unrecognized selector sent to class 0x3f2bbec4
2012-03-18 22:19:32.859 Project[14225:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIPickerTableViewTitledCell isEqualToString:]: unrecognized selector sent to class 0x3f2bbec4'

What is a UIPickerTableViewTitledCell? I suppose it is some internal class for the UIPickerView to use. But I'm not referencing that class anywhere in my project.

My application is setup as a Tab Bar application with a navigation controller in each tab and this particular tab has a tableview and pickerview.

Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
  • Run the app again and use `PO` followed by the instance listed as not responding to the selector. Is it the class you expected? Does that class implement `isEqualToString:` or do you need to get a property of the object and then check the string? – theMikeSwan Mar 18 '12 at 22:02
  • Running `po` gives me `UIPickerTableViewTitledCell`... – Peter Warbo Mar 18 '12 at 22:36
  • I'm not seeing any documentation for that class anywhere but I would imagine that is not a string but likely has a string property for its title. I haven't really worked with picker views yet so all I can really say is look for a title property or something similar. Keep in mind if it is a private class Apple will reject your app for making use of it directly (such as by calling it). – theMikeSwan Mar 18 '12 at 23:14
  • Solved it, I pinned it down to be related to the `UIPickerView`s `-pickerView:titleForRow:forComponent:` delegate method. Thanks @theMikeSwan for hinting me in the right direction. – Peter Warbo Mar 18 '12 at 23:37

1 Answers1

3

It sounds like you have an over-released object. I get that when in pre-ARC code, release is called one too many times. The code sounds like it is looking for an NSString to send isEqualToString: to but instead of getting the NSString which has been released already, it gets this random instance of UIPickerTableViewTitledCell.

I would enable Zombies. In Xcode 4.2.1, you can find it in the menu item Product > Edit Scheme. Go to the Diagnostics tab. Then there is an Enable Zombie Objects checkbox. This will make your over-released object into a Zombie, so you can figure out exactly what object is causing your crash.

I would read the Apple doc Technical Note TN2239: iOS Debugging Magic for more in-depth information on this. The whole doc is great, but you can start off by reading the sections titled "Zombies!" and "More Zombies!"

louielouie
  • 14,881
  • 3
  • 26
  • 31
  • That is true. I encountered some strange unrecognized selector exception recently. An object was released too often, so he picked an object that was `alloc`ed before the other object. Funny memory management out there. – Sebastian Wramba Mar 18 '12 at 21:48
  • The above output is what I get when I have `Enable Zombie Objects` checked. – Peter Warbo Mar 18 '12 at 22:35