03-26-2011, 12:27 AM
#1 (permalink )
Registered Member
Join Date: Mar 2011
Posts: 12
help! terminate called after throwing an instance of 'NSException'
Completely new to Xcode, using Xcode 4.
Made a simple app with tab bars. Each tab bar displays a different website (totaling up to 5).
I created the relevant controllers, etc. but I get this error: terminate called after throwing an instance of "NSException". What should I do?
Here is the code for one specific controller, ThirdViewController.
ThirdViewController.h
Code:
#import <UIKit/UIKit.h>
@interface ThirdViewController : UIViewController {
IBOutlet UIWebView *Test;
}
@end
ThirdViewController.m
Code:
#import "ThirdViewController.h"
@implementation ThirdViewController
- (void)awakeFromNib
{
[Test loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]];
}
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
*/
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc
{
[super dealloc];
}
@end
03-26-2011, 12:31 AM
#2 (permalink )
Registered Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
You'll need to paste the actual text of the exception. There are many kinds.
There's very little code in the class you posted, so I'm guessing either the .xib file is missing or the "view" outlet is not connected.
__________________
Free Games!
03-26-2011, 12:32 AM
#3 (permalink )
Registered Member
Join Date: Mar 2011
Posts: 12
Here's the error I get:
Code:
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 2933.
2011-03-26 01:22:29.311 Homework[2933:207] -[ThirdViewController _updateView]: unrecognized selector sent to instance 0x4b5a510
2011-03-26 01:22:29.314 Homework[2933:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ThirdViewController _updateView]: unrecognized selector sent to instance 0x4b5a510'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dcd5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f21313 objc_exception_throw + 44
2 CoreFoundation 0x00dcf0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d3e966 ___forwarding___ + 966
4 CoreFoundation 0x00d3e522 _CF_forwarding_prep_0 + 50
5 UIKit 0x002214ed -[UITabBar setItems:animated:] + 691
6 UIKit 0x0021dcee -[UITabBar initWithCoder:] + 220
7 Foundation 0x0078dc24 _decodeObjectBinary + 3296
8 Foundation 0x0078cd91 _decodeObject + 224
9 UIKit 0x000e1aa8 -[UITabBarController initWithCoder:] + 171
10 Foundation 0x0078dc24 _decodeObjectBinary + 3296
11 Foundation 0x0078cd91 _decodeObject + 224
12 UIKit 0x0021a979 -[UIRuntimeConnection initWithCoder:] + 212
13 Foundation 0x0078dc24 _decodeObjectBinary + 3296
14 Foundation 0x0078e9f5 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1354
15 Foundation 0x0078f024 -[NSArray(NSArray) initWithCoder:] + 596
16 Foundation 0x0078dc24 _decodeObjectBinary + 3296
17 Foundation 0x0078cd91 _decodeObject + 224
18 UIKit 0x00219c36 -[UINib instantiateWithOwner:options:] + 804
19 UIKit 0x0021bab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
20 UIKit 0x0002117a -[UIApplication _loadMainNibFile] + 172
21 UIKit 0x00021cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
22 UIKit 0x0002c617 -[UIApplication handleEvent:withNewEvent:] + 1533
23 UIKit 0x00024abf -[UIApplication sendEvent:] + 71
24 UIKit 0x00029f2e _UIApplicationHandleEvent + 7576
25 GraphicsServices 0x01006992 PurpleEventCallback + 1550
26 CoreFoundation 0x00dae944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
27 CoreFoundation 0x00d0ecf7 __CFRunLoopDoSource1 + 215
28 CoreFoundation 0x00d0bf83 __CFRunLoopRun + 979
29 CoreFoundation 0x00d0b840 CFRunLoopRunSpecific + 208
30 CoreFoundation 0x00d0b761 CFRunLoopRunInMode + 97
31 UIKit 0x000217d2 -[UIApplication _run] + 623
32 UIKit 0x0002dc93 UIApplicationMain + 1160
33 Homework 0x00002429 main + 121
34 Homework 0x000023a5 start + 53
35 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
(gdb)
03-26-2011, 12:34 AM
#4 (permalink )
Registered Member
Join Date: Mar 2011
Posts: 12
Quote:
Originally Posted by
smasher
You'll need to paste the actual text of the exception. There are many kinds.
There's very little code in the class you posted, so I'm guessing either the .xib file is missing or the "view" outlet is not connected.
The xib file isn't missing, what do u mean about the "view" outlet?
I connected "Test" to the UIWebView in the interface builder and it still doesn't work..
Last edited by hwilson; 03-26-2011 at 12:40 AM .
03-26-2011, 12:47 AM
#5 (permalink )
Super Moderator
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
This is your crash error right here:
Code:
-[ThirdViewController _updateView]: unrecognized selector sent to instance 0x4b5a510
You are calling a method called "updateView" on your view controller that you have not defined correctly. It could be as simple as a misspelling.
03-26-2011, 12:55 AM
#6 (permalink )
Registered Member
Join Date: Mar 2011
Posts: 12
Quote:
Originally Posted by
JasonR
This is your crash error right here:
Code:
-[ThirdViewController _updateView]: unrecognized selector sent to instance 0x4b5a510
You are calling a method called "updateView" on your view controller that you have not defined correctly. It could be as simple as a misspelling.
Ok, but where exactly am I calling this updateView method? The view controller is in my first post and i don't see updateView anywhere..
03-26-2011, 01:27 AM
#7 (permalink )
Registered Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Are you setting up the tabview in code or in a .xib? This can happen if you pass UIViewControllers instead of a UITabBarItems in -[UITabBar setItems: animated:]
__________________
Free Games!
03-26-2011, 06:38 AM
#8 (permalink )
Registered Member
Join Date: Mar 2011
Posts: 12
Quote:
Originally Posted by
smasher
Are you setting up the tabview in code or in a .xib? This can happen if you pass UIViewControllers instead of a UITabBarItems in -[UITabBar setItems: animated:]
Using interface builder
03-26-2011, 10:54 AM
#9 (permalink )
Registered Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
You are not calling _updateView yourself; that's something that UITabBar calls on its UITabBarItems.
It seems to be crashing before any of your code is run, so I still suspect one of your .xib files. I'd back up your project and start deleting items from the .xib one at a time until the crashing stops. Then you'll have some idea where to look next.
I'd start with wherever ThirdViewController is used in the nib; make sure it's not a child of a tab bar. It should be the child of a tab bar controller.
This could also happen if you're incorrectly releasing a UITabBarItem somewhere, but I doubt it.
__________________
Free Games!
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 371
12 members and 359 guests
condor304 , dansparrow , Domele , dre , dreamdash3 , ilmman , LezB44 , michelle , Sami Gh , shagor012 , thephotographer , tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44