Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Very basic problem with Tab Bar Application and Interface Builder

OK, here is how to re-create the problem I have:

1) Create a new project, using the Tab Bar Application
2) Add a UILabel within SecondView.xib
3) Add IBOutlet UILabel* myLabel; to FirstViewController.h
4) Connect up myLabel in IB.
5) Build and run.

When I click the second tab the app crashes with:

_TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION_

I can't figure it out!

Any help much appreciated.

Cheers,
Rew

MacBook 2.1 GHz IntelCore2Duo 4GB DDR2 SDRAM, Mac OS X (10.5.4)

Posted on Jul 12, 2008 5:32 AM

Reply
27 replies

Jun 10, 2009 10:42 AM in response to rew.islam

Thank you for your answer and I think this might be the solution I've been looking for.

Although, I'm a newbie coding this one up and I've gotten a little confused. When I set up my project in Xcode, I used the TabBar Template to make implementation a little bit easier. However, when I start doing actual code, it all crashes.

I have UIViewControllers for each View but I only have one UITabBarController. Where I am lost is with the second part. "In each UIViewController, not only do you set your NIB file, but also the class". Do you have a screen shot of this or can someone else provide this. I'm more of a visual learner and I would greatly appreciate it.

Thanks!

Jan 25, 2010 3:52 AM in response to rew.islam

You may have posted this over a year ago, but it just helped me today!
And might I say that I couldn't find this advice ANYWHERE else, after searching for over an hour using the exact error message that you reported.

How annoying that you need to specify the class name of each view controller in both the view's NIB file, and the tab bar NIB file... I'm still trying to get my head around the logic of that!

Mar 16, 2010 4:17 AM in response to rew.islam

Hello,
i create a uiTabBarController manually using the code,it has a UITableViewController.
This one calls a RSS feed,by selecting a cell i should have a UIWebView showing the details for each row selected.

I had the same probleme,but unfortunatly i could not solve it 😟

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UITableViewCell 0x3910ce0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key label1.


when i checked my code using breakpoint ,i found that the error is may be coming from :
cell = (TableViewCell *) c.view;


and this is the method :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"CellIndent";

TableViewCell *cell = (TableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
UIViewController *c = [[UIViewController alloc] initWithNibName:@"TableViewCell" bundle:nil];
cell = (TableViewCell *) c.view;
[c release];
}

// Set up the cell...
int storyIndex = [indexPath indexAtPosition:[indexPath length]-1];
cell.label1.text =[[stories objectAtIndex:storyIndex] objectForKey:@"title"];
return cell;
}

Very basic problem with Tab Bar Application and Interface Builder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.