Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 29, 2008, 03:36 PM   #1
roeik
macrumors member
 
Join Date: Dec 2008
Unrecognized selector sent to instance ERROR using UITabBarController

Hi,

I need help desperately. I keep getting the following error:

2008-12-29 21:28:23.609 TabApplication[7510:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIViewController printSomething]: unrecognized selector sent to instance 0x529c80'

I basically created a UIButton and connected an action to it -- nothing too fancy. But I keep getting this error. I think it has something to do with the UITabBarController. Everything works well on the MainWindow.xib, but this error is generated on another .xib file which is loaded by the second UITabItem. I used the built-in Tab Bar application when I created the project.

Any suggestions? Please. I lost two days on this error.
Thanks.
Roei.
roeik is offline   0 Reply With Quote
Old Dec 29, 2008, 03:41 PM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Can you show us how printSomething is defined and how you are calling it?
dejo is offline   0 Reply With Quote
Old Dec 29, 2008, 04:13 PM   #3
roeik
Thread Starter
macrumors member
 
Join Date: Dec 2008
The interface:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface UpdateController : NSObject {
}

-(IBAction) printSomething;

@end

in the implementation file I have this function:

-(IBAction) printSomething {
NSLog(@"Roei");
}

I don't call the function specifically from anywhere. I connected the Touch up inside event to printSomething using the connection inspector in interface builder.

Thank you for trying to help.

Roei
roeik is offline   0 Reply With Quote
Old Dec 29, 2008, 04:48 PM   #4
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
I believe IBActions are sent a 'sender' parameter when hooked up via IB. Therefore, try this instead:
Code:
@interface UpdateController : NSObject {
}

-(IBAction) printSomething:(id)sender;

@end
and then:
Code:
-(IBAction) printSomething:(id)sender {
NSLog(@"Roei");
}
dejo is offline   0 Reply With Quote
Old Dec 29, 2008, 08:16 PM   #5
roeik
Thread Starter
macrumors member
 
Join Date: Dec 2008
I tried this before. I keep getting the same error:

2008-12-30 03:13:11.100 TabApplication[8883:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIImageView printSomething]: unrecognized selector sent to instance 0x59f6a0'

any other ideas?
roeik is offline   0 Reply With Quote
Old Dec 29, 2008, 08:48 PM   #6
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Hmm, you really want your UpdateController to be a subclass of NSObject and not UIViewController?

And I'm just reaching for straws at this point. Not really sure what the issue is without seeing more of the code and the .xib file, which is kinda hard for you to pass on.
dejo is offline   0 Reply With Quote
Old Dec 30, 2008, 09:24 AM   #7
roeik
Thread Starter
macrumors member
 
Join Date: Dec 2008
well, I tried both ways. it doesn't help.
roeik is offline   0 Reply With Quote
Old Dec 30, 2008, 02:24 PM   #8
roeik
Thread Starter
macrumors member
 
Join Date: Dec 2008
Hey,

So I isolated the problem and I am definitely doing something wrong using the built-in tab controller.

To facilitate the process and for order to you to see exactly what happens I detailed the steps I have taking (when creating a new tab bar application) that results the error I am getting.

This is what I do: in xCode I started a new project --> new Tab Bar Application.

I double-clicked the secondView.xib that was created. I dragged a button from the library to the view. I also dragged another Object and named the class controller (subclassing NSObject). I created a new action using Interface Builder called printSomething. Then I chose file-->write class files and in the printSomething function just put an NSLog. Using the connection inspector, I connected the Touch Up Inside event of the button to printsomething in the controller. If you follow all these steps (they take two minutes), you will get an error when clicking the button. What am I doing wrong?

Thank you for your help.

Roei
roeik is offline   0 Reply With Quote
Old Dec 30, 2008, 06:45 PM   #9
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by roeik View Post
I also dragged another Object and named the class controller (subclassing NSObject). I created a new action using Interface Builder called printSomething.
I'm kinda unclear what you're doing in this part and what purpose it's meant to accomplish. Can you elaborate?
dejo is offline   0 Reply With Quote
Old Dec 30, 2008, 07:11 PM   #10
roeik
Thread Starter
macrumors member
 
Join Date: Dec 2008
I am creating another file in the .xib bundle where I write my functions(Actions) and connect them to the UIControls in the view.
roeik is offline   0 Reply With Quote
Old Dec 30, 2008, 09:20 PM   #11
roeik
Thread Starter
macrumors member
 
Join Date: Dec 2008
Let me phrase my question differently. After creating a new Tab Bar application, who will y ou go about creating a button on the second screen does something (i.e. print an NSLog comment)?
roeik is offline   0 Reply With Quote
Old Dec 30, 2008, 11:13 PM   #12
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by roeik View Post
Let me phrase my question differently. After creating a new Tab Bar application, who will y ou go about creating a button on the second screen does something (i.e. print an NSLog comment)?
I'm working on what I would do.

In the mean time, maybe this tutorial can give you some direction, although it doesn't demonstrate your exact requirement:
http://icodeblog.com/2008/10/13/ipho...between-views/
dejo is offline   0 Reply With Quote
Old Dec 31, 2008, 01:06 PM   #13
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
I'm beginning to think that starting with the Tab Bar Application template is more of a hindrance than a help. I've had luck adding a second ViewController subclass but can't seem to get the event for the button hooked to any IBAction.

So, I'm gonna suggest that you might be better off starting off with less in your initial project. Here's another tutorial that follows that mindset a little closer: Tab Bar Controller Tutorial
dejo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
"Unrecognized selector" error when attempting to remove an object while in a for loop moonman239 iPhone/iPad Programming 18 Feb 26, 2014 08:29 AM
Resolved: [_NSCFNumber setTableViewStyle:] unrecognized selector set to instance moonman239 iPhone/iPad Programming 2 Nov 18, 2013 07:14 PM
Resolved: Unrecognized selector sent to instance Blakeasd iPhone/iPad Programming 2 Jul 2, 2013 09:01 PM
unrecognized selector sent to instance with Coredata and Category of NSMangedObject roeik iPhone/iPad Programming 5 Sep 5, 2012 06:40 AM
unrecognized selector larswik iPhone/iPad Programming 6 Jun 20, 2012 11:46 PM

Forum Jump

All times are GMT -5. The time now is 01:35 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC