Error during Navigation point - iphone

I have created one navigation based application. In that first view show me the list of the drinks and in second view it show me the Details of the Drinks.
All seems ok but while i am navigatting the view at (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath Method, It will show me the error like
terminate called after throwing an instance of 'NSException'
at line
[self.navigationController pushViewController:drinkDetailViewController animated:YES];
Plese help me, why it happens like that ?
My code for the method is as follow:
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DrinkDetailViewController *drinkDetailViewController = [[DrinkDetailViewController alloc] initWithNibName:#"DrinkDetailViewController" bundle:nil];
//UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:drinkDetailViewController];
//[self presentModalViewController:drinkDetailViewController animated:YES];
//[self dismissModalViewControllerAnimated:YES];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:drinkDetailViewController animated:YES];
[drinkDetailViewController release];
}
While i click on row, it shows me that exception message.
This is project log:
2011-08-10 10:18:10.559 DrinkMixer_Shreyash[694:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "DrinkDetailViewController" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00d7aef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d7ae6a +[NSException raise:format:] + 58
4 UIKit 0x000c6709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x000c4134 -[UIViewController loadView] + 120
6 UIKit 0x000c400e -[UIViewController view] + 56
7 UIKit 0x000c2482 -[UIViewController contentScrollView] + 42
8 UIKit 0x000d2f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
9 UIKit 0x000d1555 -[UINavigationController _layoutViewController:] + 43
10 UIKit 0x000d27aa -[UINavigationController _startTransition:fromViewController:toViewController:] + 326
11 UIKit 0x000cd32a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
12 UIKit 0x000d4562 -[UINavigationController pushViewController:transition:forceImmediate:] + 932
13 UIKit 0x000cd1c4 -[UINavigationController pushViewController:animated:] + 62
14 DrinkMixer_Shreyash 0x000029bf -[RootViewController tableView:didSelectRowAtIndexPath:] + 191
15 UIKit 0x0008bb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
16 UIKit 0x00081b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
17 Foundation 0x0079b79e __NSFireDelayedPerform + 441
18 CoreFoundation 0x00da38c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
19 CoreFoundation 0x00da4e74 __CFRunLoopDoTimer + 1220
20 CoreFoundation 0x00d012c9 __CFRunLoopRun + 1817
21 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
22 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
23 GraphicsServices 0x00ffa1c4 GSEventRunModal + 217
24 GraphicsServices 0x00ffa289 GSEventRun + 115
25 UIKit 0x00022c93 UIApplicationMain + 1160
26 DrinkMixer_Shreyash 0x00002089 main + 121
27 DrinkMixer_Shreyash 0x00002005 start + 53
28 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
(gdb)
Please help me regarding it. . .

iDroid Exploer , in your drinkDetailViewController class you have to connect the view variable to the view element of the Xib file. It has to be done via interface builder.

This is the crash regarding that your IBOutlet for View in DrinkDetailViewController is not set in XIB file. Please set Your View in XIB and then try to run the app. This is done using Interface builder..
Happy Coding...

Related

App crash after modification on the XIB files

After adding a new searchbar on the RootViewController.xib, and connecting it with the FileOwner, the App will crash. It reports the stack when crash:
2011-07-17 17:12:43.756 TableView[1397:207] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: '-[UIViewController
_loadViewFromNibNamed:bundle:] loaded the "RootViewController" nib but the view outlet
was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc85a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f1c313 objc_exception_throw + 44
2 CoreFoundation 0x00d80ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d80e6a +[NSException raise:format:] + 58
4 UIKit 0x0036a709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x00368134 -[UIViewController loadView] + 120
6 UIKit 0x004c1dd8 -[UITableViewController loadView] + 80
7 UIKit 0x0036800e -[UIViewController view] + 56
8 UIKit 0x003667f5 -[UIViewController nextResponder] + 34
9 UIKit 0x003874a6 -[UIResponder _containsResponder:] + 41
10 UIKit 0x00371c4e -[UINavigationController defaultFirstResponder] + 80
11 UIKit 0x00386647 -[UIResponder(Internal) _deepestDefaultFirstResponder] + 42
12 UIKit 0x00386663 -[UIResponder(Internal) _deepestDefaultFirstResponder] + 70
13 UIKit 0x00386406 -[UIResponder(Internal) _promoteDeepestDefaultFirstResponder] + 42
14 TableView 0x00002a0a -[TableViewAppDelegate application:didFinishLaunchingWithOptions:] + 135
15 UIKit 0x002b8c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
16 UIKit 0x002bad88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
17 UIKit 0x002c5617 -[UIApplication handleEvent:withNewEvent:] + 1533
18 UIKit 0x002bdabf -[UIApplication sendEvent:] + 71
19 UIKit 0x002c2f2e _UIApplicationHandleEvent + 7576
20 GraphicsServices 0x01720992 PurpleEventCallback + 1550
21 CoreFoundation 0x00da9944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
22 CoreFoundation 0x00d09cf7 __CFRunLoopDoSource1 + 215
23 CoreFoundation 0x00d06f83 __CFRunLoopRun + 979
24 CoreFoundation 0x00d06840 CFRunLoopRunSpecific + 208
25 CoreFoundation 0x00d06761 CFRunLoopRunInMode + 97
26 UIKit 0x002ba7d2 -[UIApplication _run] + 623
27 UIKit 0x002c6c93 UIApplicationMain + 1160
28 TableView 0x00002960 main + 102
29 TableView 0x000028f1 start + 53
30 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Well I don't know what you want us to tell you more then your error is already telling you.
Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: '-[UIViewController
_loadViewFromNibNamed:bundle:] loaded the "RootViewController" nib but
the view outlet was not set.'
That is that you forgot to connect your view outlet of your RootViewController so it does not know what to load. The RootViewController of your MainWindow is the first thing that's going to be loaded, if it does not know what view it should display it will give you the above error.

simple app crashing?

I have a very simple window based app, i am simply putting a navigation view controller as window's root view controller and it's crashing. This is the only thing i changed in the template project:
#interface AppDelegate : NSObject <UIApplicationDelegate> {
UINavigationController *navigationController;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
navigationController = [[UINavigationController alloc] init];
[[self window] setRootViewController:navigationController];
[self.window makeKeyAndVisible];
return YES;
}
It crashes saying:
2011-05-26 20:18:57.194 ZebraSDKTest[5560:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x8b3d760> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key navigationController.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dbf5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f13313 objc_exception_throw + 44
2 CoreFoundation 0x00dbf4e1 -[NSException raise] + 17
3 Foundation 0x00791677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x007915e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x0020d30c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d358cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x0020bd23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x0020dab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x0001317a -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x00013cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
11 UIKit 0x0001e617 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit
0x00016abf -[UIApplication sendEvent:] + 71
13 UIKit 0x0001bf2e _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x00ff8992 PurpleEventCallback + 1550
15 CoreFoundation 0x00da0944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00d00cf7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00cfdf83 __CFRunLoopRun + 979
18 CoreFoundation 0x00cfd840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00cfd761 CFRunLoopRunInMode + 97
20 UIKit 0x000137d2 -[UIApplication _run] + 623
21 UIKit 0x0001fc93 UIApplicationMain + 1160
22 ZebraSDKTest 0x00002549 main + 121
23 ZebraSDKTest 0x000024c5 start + 53
)
Looks like you have a connection to a former existing UINavigationController IBOutlet in one of your nib files.
Start with MainWindow.xib and check for such a connection.
I had this problem occurring on the simulator only, but on the device it was working fine.
I tried cleaning the project, restarting Xcode, debugging, emptying the simulator data, the whole works.
In the end it was resolved by uninstalling the app from the simulator and reinstalling it. No idea why that worked, but it solved it!

Universal app crashes on iPad simulator at each alternate time

My app crashes on iPad simulator in alternate builds, crash then run then crash, etc.
objc[1116]: Class Protocol is implemented in both /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/libobjc.A.dylib and /Users/NGA24iMAC3/Library/Application Support/iPhone Simulator/4.2/Applications/C0FFA7D7-7684-4854-B641-62BD11CFD226/Innovations.app/Innovations. One of the two will be used. Which one is undefined.
2011-02-09 11:53:01.446 Innovations[1116:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PadLoginScreen" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x01286be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x013db5c2 objc_exception_throw + 47
2 CoreFoundation 0x0123f628 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x0123f59a +[NSException raise:format:] + 58
4 UIKit 0x004a2b75 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x004a0709 -[UIViewController loadView] + 120
6 UIKit 0x004a05e3 -[UIViewController view] + 56
7 UIKit 0x0049ea57 -[UIViewController contentScrollView] + 42
8 UIKit 0x004af201 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
9 UIKit 0x004ad831 -[UINavigationController _layoutViewController:] + 43
10 UIKit 0x004aeb4c -[UINavigationController _startTransition:fromViewController:toViewController:] + 524
11 UIKit 0x004a9606 -[UINavigationController _startDeferredTransitionIfNeeded] + 266
12 UIKit 0x004b083e -[UINavigationController pushViewController:transition:forceImmediate:] + 932
13 UIKit 0x004a94a0 -[UINavigationController pushViewController:animated:] + 62
14 Innovations 0x00006172 -[SplashScreenController switchView] + 303
15 Foundation 0x001887a5 __NSFireTimer + 125
16 CoreFoundation 0x01267fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
17 CoreFoundation 0x01269594 __CFRunLoopDoTimer + 1220
18 CoreFoundation 0x011c5cc9 __CFRunLoopRun + 1817
19 CoreFoundation 0x011c5240 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x011c5161 CFRunLoopRunInMode + 97
21 GraphicsServices 0x01b52268 GSEventRunModal + 217
22 GraphicsServices 0x01b5232d GSEventRun + 115
23 UIKit 0x0040142e UIApplicationMain + 1160
24 Innovations 0x00002e70 main + 102
25 Innovations 0x00002e01 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
But all outlet set correctly in IB.Please help me.Thanx in advance.
#Ishu i think that something is wrong with your connections in IB.I know you checked your IB but can you make your .xib file once again.
I suggest cleaning your project. Command + Shift + K
Next, open your XIB file and verify that the view outlet of the "File's Owner" is connected to your view. Of not connect and it and save.
Rebuild your project.
I also faced same problem in my Universal app .
I did something like this that solved my problem -
- (id)initWithNibName:(NSString *)n bundle:(NSBundle *)b
{
return [self init];
}
- (id)init
{
BOOL iPad = NO;
#ifdef UI_USER_INTERFACE_IDIOM
iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#endif
if (iPad)
{
// iPad specific code here
NSLog(#"Device is iPad");
[super initWithNibName:#"ContactUsViewController~ipad" bundle:nil];
} else
{
// iPhone/iPod specific code here
NSLog(#"Device is iPhone");
[super initWithNibName:#"ContactUsViewController" bundle:nil];
}
return self;
}
when you are adding/pushing viewController just call its init method and then push viewcontroller.
Open our iPad xib in Interface Builder
Click on File's ownner
In the Inspector, go to the fourth tab (Identity)
Write as class identity the name of the class that is acting as view controller for that xib.
Ready to go!

app crashes after xib edit

I have a navigation controller app. I created a RootViewController class with Xib file. In that xib file I had table view and nothing more else. Toolbar and buttons on the toolbar I created in program way. Table view had datasourse and delegate File Owner.
I deleted this xib file, and created a new one with previous name. Created it like viewBased xib file and then I dropped down to it table view, toolbar, two buttons on toolbar. Add outlets on them. Saved it all. Clear all targets. Build all. And Run. Application crashes on start! Anyone know where may be the problem? Thanx!
Stack:
[Session started at 2010-11-16 15:00:52 +0200.]
2010-11-16 15:00:53.729 PhoneBook[16210:207] ******* Accessibility Status Changed: On
2010-11-16 15:00:53.755 PhoneBook[16210:207] ********** Loading AX for: com.yourcompany.PhoneBook ************
2010-11-16 15:00:53.798 PhoneBook[16210:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "RootViewController" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x02510b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0266040e objc_exception_throw + 47
2 CoreFoundation 0x024c9238 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x024c91aa +[NSException raise:format:] + 58
4 UIKit 0x0036aa40 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x00368675 -[UIViewController loadView] + 120
6 UIKit 0x004c1c8c -[UITableViewController loadView] + 80
7 UIKit 0x0036854f -[UIViewController view] + 56
8 UIKit 0x003669f4 -[UIViewController contentScrollView] + 42
9 UIKit 0x003767e2 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
10 UIKit 0x00374ea3 -[UINavigationController _layoutViewController:] + 43
11 UIKit 0x0037612d -[UINavigationController _startTransition:fromViewController:toViewController:] + 524
12 UIKit 0x00370ccd -[UINavigationController _startDeferredTransitionIfNeeded] + 266
13 UIKit 0x0048db55 -[UILayoutContainerView layoutSubviews] + 226
14 QuartzCore 0x0456a481 -[CALayer layoutSublayers] + 177
15 QuartzCore 0x0456a1b1 CALayerLayoutIfNeeded + 220
16 QuartzCore 0x045632e0 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 302
17 QuartzCore 0x04563040 _ZN2CA11Transaction6commitEv + 292
18 UIKit 0x002c104e -[UIApplication _reportAppLaunchFinished] + 39
19 UIKit 0x002c1477 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 545
20 UIKit 0x002cb3ec -[UIApplication handleEvent:withNewEvent:] + 1958
21 UIKit 0x002c3b3c -[UIApplication sendEvent:] + 71
22 UIKit 0x002c89bf _UIApplicationHandleEvent + 7672
23 GraphicsServices 0x02d6c822 PurpleEventCallback + 1550
24 CoreFoundation 0x024f1ff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
25 CoreFoundation 0x02452807 __CFRunLoopDoSource1 + 215
26 CoreFoundation 0x0244fa93 __CFRunLoopRun + 979
27 CoreFoundation 0x0244f350 CFRunLoopRunSpecific + 208
28 CoreFoundation 0x0244f271 CFRunLoopRunInMode + 97
29 UIKit 0x002c0c6d -[UIApplication _run] + 625
30 UIKit 0x002ccaf2 UIApplicationMain + 1160
31 PhoneBook 0x00002494 main + 102
32 PhoneBook 0x00002425 start + 53
)
terminate called after throwing an instance of 'NSException'
* Terminating app due to uncaught exception
'NSInternalInconsistencyException',
reason: '-[UIViewController
_loadViewFromNibNamed:bundle:] loaded the "RootViewController" nib but the
view outlet was not set.'
Your view controller lost connection for view outlet, you need to restore it in IB (as you do with all outlets)

App terminates after viewcontroller calls the delegate to close the view

here the situation: i have a viewcontroller which calls in the function "viewDidLoad" a function in the AppDelegateIphone to terminate this view.
The problem is that this exception comes if i make this:
splashScreen.view = nil;
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SplashScreenController_iPhone" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x029dc919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02b2a5de objc_exception_throw + 47
2 CoreFoundation 0x02995078 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x02994fea +[NSException raise:format:] + 58
4 UIKit 0x0062a09c -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x00627cd1 -[UIViewController loadView] + 120
6 UIKit 0x00627bab -[UIViewController view] + 56
7 regioappv2 0x00003085 -[AppDelegate_iPhone application:didFinishLaunchingWithOptions:] + 97
8 UIKit 0x00580543 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
9 UIKit 0x005829a1 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 346
10 UIKit 0x0058c452 -[UIApplication handleEvent:withNewEvent:] + 1958
11 UIKit 0x00585074 -[UIApplication sendEvent:] + 71
12 UIKit 0x00589ac4 _UIApplicationHandleEvent + 7495
13 GraphicsServices 0x030bfafa PurpleEventCallback + 1578
14 CoreFoundation 0x029bddc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
15 CoreFoundation 0x0291e737 __CFRunLoopDoSource1 + 215
16 CoreFoundation 0x0291b9c3 __CFRunLoopRun + 979
17 CoreFoundation 0x0291b280 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x0291b1a1 CFRunLoopRunInMode + 97
19 UIKit 0x00582226 -[UIApplication _run] + 625
20 UIKit 0x0058db58 UIApplicationMain + 1160
21 regioappv2 0x000028b4 main + 102
22 regioappv2 0x00002845 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
if I call the function with the splashScreen.view = nil; in the appDelegate itself, then everything is working just fine.
Please tell me where is my fault, or wheather I should post more code.
regards
loaded the "SplashScreenController_iPhone" nib but the view outlet was not set.
Have you made the view outlet in interface builder? Seems that you have not set it up correctly. And also from the stack trace, it's clear that viewDidLoad haven't been called, as the view is yet to be successfully loaded.