Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > unrecognized selector sent to instance ...

unrecognized selector sent to instance ...
Thread Tools
orlin61
Fresh-Faced Recruit
Join Date: Jun 2008
Status: Offline
Reply With Quote
Jun 12, 2008, 08:54 AM
 
Hi everybody

I'm a newbee in iPhone programming and I'm currently trying to develop a Snake-like to get used to the iPhone SDK. Unfortunatly I have an error I can't solve. I created a view with a button on it and wanted this button to switch the menu view to the game view. Unfortunatly I have this error :

Code:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType buttonClicked:]: unrecognized selector sent to instance 0x44e1e0'
I do not understand because I have the following line in my code :

Code:
@interface SnakeMenuController : UIViewController { } - (IBAction)buttonClicked:(id)sender; @end
and :

Code:
@implementation SnakeMenuController ... - (IBAction)buttonClicked:(id)sender { NSLog(@"Start button pressed"); } ...
To conclude, I'd like to inform you I used (or maybe tried to use) Interface Builder to connect my action with the TouchUpInside Event of my button.

Thanks a lot for your help.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jun 12, 2008, 11:19 AM
 
Are you sure you've actually got a SnakeMenuController that's receiving the message, rather than something else?
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
orlin61  (op)
Fresh-Faced Recruit
Join Date: Jun 2008
Status: Offline
Reply With Quote
Jun 12, 2008, 01:25 PM
 
In my .xib file, I defined the SnakeMenuController as Fil's Owner and then I connected the buttonClicked: method to the Touch Up Inside Event of my button (which is inserted on the View). Reading the error message I tought my mistake was I called buttonClicked under the wrong object so I decided to connect my action manually but the result was exactly the same. I really do not understand why I have this problem because I checked with example given by Apple
     
kido331
Junior Member
Join Date: May 2007
Status: Offline
Reply With Quote
Jun 12, 2008, 01:30 PM
 
could you connection be backwards? make sure you connect from the button to the controller when you set up your buttonClicked binding.
     
orlin61  (op)
Fresh-Faced Recruit
Join Date: Jun 2008
Status: Offline
Reply With Quote
Jun 12, 2008, 01:40 PM
 
make sure you connect from the button to the controller when you set up your buttonClicked binding.
No I started from the Controller. I thought it was possible in Interface Builder to connect action from the destination to the source. Are you telling me I have to start from the button event and then connect the blue line in my File's Owner?

PS : I'm sorry if my english is not perfect or if you don't understand everything I'm writing. Do not hesitate to tell me if you don't understand my posts. I'm french and if you ask my I can try to reformulate my sentences
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jun 12, 2008, 05:41 PM
 
Originally Posted by orlin61 View Post
No I started from the Controller. I thought it was possible in Interface Builder to connect action from the destination to the source. Are you telling me I have to start from the button event and then connect the blue line in my File's Owner?
I don't do iPhone development, but source->destination is the only way to do it in the normal Interface Builder.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
orlin61  (op)
Fresh-Faced Recruit
Join Date: Jun 2008
Status: Offline
Reply With Quote
Jun 13, 2008, 03:05 AM
 
I just tried to delete the previous connection and create another one starting from the source ('Touch Up Inside' event of my button) to the destination (my File's Owner which is my SnakeMenuController) and there is no change : I still have this error "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType buttonClicked:]: unrecognized selector sent to instance 0x44e1e0'"
I don't know how Interface Builder works but do you think it is possible it is trying to connect my event to the buttonClicked: action from an object which type is different from SnakeMenuController.
     
bdobry
Fresh-Faced Recruit
Join Date: Mar 2009
Status: Offline
Reply With Quote
Mar 21, 2009, 08:58 PM
 
I know this thread is a little old, but i am having the same problem and cannot figure it out. Any resolution?
     
YenZi
Fresh-Faced Recruit
Join Date: Mar 2009
Status: Offline
Reply With Quote
Mar 28, 2009, 05:59 PM
 
I had the same problem that was described in this thread. After quite some time I noticed, that in the inspector (right most tab "identity") for my ViewController the class was still set to "UIViewController" instead of the ViewController that contained the IBAction method. So, it's not only setting the File's owner in your nib window to your ViewController class, but also you need to set the class of the ViewController to your particular one, not the UIViewController. Look for the ViewController in your MainWindow.xib, select it, open the inspector and change class in the identity tab.

HTH,

YenZi
     
robertjd
Fresh-Faced Recruit
Join Date: Jun 2009
Status: Offline
Reply With Quote
Jun 5, 2009, 10:39 AM
 
I'd like to make note of another situation where this problem can occur:

When using Interface Builder, if you have setup a Navigation Controller and if the View Controller that is nested in the nav controller is in a different XIB file, you will need to make sure to set the Class for the View Controller where it shows up nested in your Navigation Controller AND on the File Owner in the other XIB. If you don't have the class specified in both places, you will get the unrecognized selector error.
     
keveridge
Fresh-Faced Recruit
Join Date: Apr 2001
Location: London, UK
Status: Offline
Reply With Quote
Aug 5, 2009, 08:07 AM
 
This thread helped me out hugely when using a UITabBarController with 4 ViewControllers using separate xib files.

I had a UITableView that couldn't find the appropriate ViewController class I'd created until I selected the appropriate tab (not the tab item / image) and selecting the appropriate class under identity -> class identity -> class.

It then worked like a charm
     
ovycom
Fresh-Faced Recruit
Join Date: Feb 2010
Status: Offline
Reply With Quote
Feb 16, 2010, 06:27 AM
 
I have a this situation, a navcontroller, tab controller, and View Controller, and in the first tab view coltroller in interface I added a pushbutton. All is work, but when i try to push button i will get the error "unrecognized selector sent to instance UIViewController".
Anybody know?


Originally Posted by robertjd View Post
I'd like to make note of another situation where this problem can occur:

When using Interface Builder, if you have setup a Navigation Controller and if the View Controller that is nested in the nav controller is in a different XIB file, you will need to make sure to set the Class for the View Controller where it shows up nested in your Navigation Controller AND on the File Owner in the other XIB. If you don't have the class specified in both places, you will get the unrecognized selector error.
     
Warhaven
Dedicated MacNNer
Join Date: Jul 2002
Status: Offline
Reply With Quote
Mar 3, 2010, 05:35 PM
 
Originally Posted by ovycom View Post
I have a this situation, a navcontroller, tab controller, and View Controller, and in the first tab view coltroller in interface I added a pushbutton. All is work, but when i try to push button i will get the error "unrecognized selector sent to instance UIViewController".
Anybody know?
Only thing I can suggest is to make sure your class in IB is pointing to the class that has your button's IBAction:




Then simply control-click-drag from your button to your class in IB and select the IBAction:


     
eqajize
Fresh-Faced Recruit
Join Date: Mar 2010
Status: Offline
Reply With Quote
Mar 5, 2010, 04:33 AM
 
Hi, I have the same problem...
My app has a tab view with 3 view controller and a nav controller.
In the nav controller i have put a view controller and a external nib, all is ok I can start my app and navigate through the tab nav.
When I try to put an action on a button in my nib file (in my nav controller), I got the error above...
I have my own view controller for this nib and the action in it... I have linked it in IB on the button...
And the only action is NSLOG(@"test")...
I've been looking for it on the net for last 3 days, I'm going mad...
Can someone please help me ?
     
eqajize
Fresh-Faced Recruit
Join Date: Mar 2010
Status: Offline
Reply With Quote
Mar 5, 2010, 06:19 AM
 
oups... sorry for the noise...
my declaration in the .h was mistaken...
All is ok now...
     
ipad newbie
Fresh-Faced Recruit
Join Date: Apr 2010
Status: Offline
Reply With Quote
Apr 21, 2010, 02:12 AM
 
So what was your mistake in .h file? I am running into a similar problem for a button in a subview. It seems that I have followed everything suggested here, i.e., the delegate connection, class identity. I loaded the subview via xib file and manually added to the parent view. I don't know if that's a problem. Any help is much appreciated!

Originally Posted by eqajize View Post
oups... sorry for the noise...
my declaration in the .h was mistaken...
All is ok now...
     
aleks512
Fresh-Faced Recruit
Join Date: May 2011
Status: Offline
Reply With Quote
May 12, 2011, 06:17 AM
 
God bless you man
I had the same problem but with the Tab Bar Controller. The class was not specified in the Interface Builder for that specific view controller.
Half a day of frustrations is gone

Cheers
     
msuper69
Professional Poster
Join Date: Jan 2000
Location: Columbus, OH
Status: Offline
Reply With Quote
May 13, 2011, 12:37 PM
 
Real programmers don't use IB; they do it all in code.
IB is nothing but a pain-in-the-a$$.
     
becker666
Fresh-Faced Recruit
Join Date: Aug 2011
Status: Offline
Reply With Quote
Aug 4, 2011, 08:37 PM
 
This thread is been going for a little while and the song remains the same

I had such a simple GUI : tabcontroller and 3 views so I used IB and got the actual code to process the stuff worked out, so I said not so bad for the IB .. NOT quite I tried to add a 4th View now this thing popped ...or is it pooped out of nowhere it is not taking the links and wrong key, unrecognised selector,blah blah blah

Not worth it trying to figure out my App was almost done so did this view and next ones by hand and all is good. Actually IB can be used to get the coordinates and stuff but that's it for heavy duty stuff it doesn't cut it. nib2obj comes in handy to get the code behind a GUI layout. So agreed real-coders don't use that or just use it as a reference.

Cheers
     
russellcarswell
Fresh-Faced Recruit
Join Date: Aug 2011
Status: Offline
Reply With Quote
Aug 15, 2011, 07:13 PM
 
I had the same problem, it turned out that it was a memory management mistake on my part - everything was hooked up correctly in IB but in the class from which I added the view I released it too soon - the freed memory was then re-allocated for a new object in my case a NSCFType, so the method call was on that, and therefore the selector wasn't recognised.

See article: Strange Objects (NSCFType, etc.) Indicate Memory Management Bugs. � IMLocation development log
     
edf456
Fresh-Faced Recruit
Join Date: Jan 2012
Status: Offline
Reply With Quote
Jan 31, 2012, 09:21 AM
 
If you use Tab Bar Controller that cause this problem, please try click Tab Bar Controller's button and select Custom Class.
     
dwadelson
Fresh-Faced Recruit
Join Date: May 2013
Status: Offline
Reply With Quote
May 14, 2013, 04:43 AM
 
Originally Posted by YenZi View Post
I had the same problem that was described in this thread. After quite some time I noticed, that in the inspector (right most tab "identity") for my ViewController the class was still set to "UIViewController" instead of the ViewController that contained the IBAction method. So, it's not only setting the File's owner in your nib window to your ViewController class, but also you need to set the class of the ViewController to your particular one, not the UIViewController. Look for the ViewController in your MainWindow.xib, select it, open the inspector and change class in the identity tab.

HTH,

YenZi
i had exactly the same problem, and YenZi's solution solved it, but it took me awhile to understand exactly what YenZi meant...i was going to each of my custom controllers for my tabs and trying to make the change, and that's not the problem...you have to go to your tab view controller class...when i looked at the objects in that class, i.e. the root controller nib, i saw that those objects were all listed as UIViewControllers...so i selected each ViewController, and then went to the Identity Inspector, and changed the class of each of these to my custom class, and then everything worked fine...
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:31 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,