Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

roeik

macrumors member
Original poster
Dec 25, 2008
80
0
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

macrumors member
Original poster
Dec 25, 2008
80
0
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
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
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");
}
 

roeik

macrumors member
Original poster
Dec 25, 2008
80
0
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?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
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.
 

roeik

macrumors member
Original poster
Dec 25, 2008
80
0
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
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
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?
 

roeik

macrumors member
Original poster
Dec 25, 2008
80
0
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

macrumors member
Original poster
Dec 25, 2008
80
0
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)?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.