Question

I am building/learning my first Xcode app. I've used C before, and am attempting to learn Objective C to build iPhone apps.

I've built a simple app, and when I run the iOS simulator, and press a button which refers to another screen in my storyboard, the app crashes. I've built the entire app thus far using storyboard.

This is my entire main.m file...

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char * argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

This is the error...

2014-03-02 21:22:04.422 Meal Plan Generator[4777:70b] * Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.' * First throw call stack: ( 0 CoreFoundation 0x00000001018a2795 exceptionPreprocess + 165 1 libobjc.A.dylib
0x00000001015ee991 objc_exception_throw + 43 2 UIKit
0x00000001006ef051 -[UIStoryboardPushSegue destinationContainmentContext] + 0 3 UIKit
0x0000000100252096 -[UIApplication sendAction:to:from:forEvent:] + 80 4 UIKit 0x0000000100252044 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17 5 UIKit 0x0000000100326450 -[UIControl _sendActionsForEvents:withEvent:] + 203 6 UIKit 0x00000001003259c0 -[UIControl touchesEnded:withEvent:] + 530 7
UIKit 0x0000000100286c15 -[UIWindow _sendTouchesForEvent:] + 701 8 UIKit 0x0000000100287633 -[UIWindow sendEvent:] + 988 9 UIKit
0x0000000100260fa2 -[UIApplication sendEvent:] + 211 10 UIKit
0x000000010024ed7f _UIApplicationHandleEventQueue + 9549 11 CoreFoundation 0x0000000101831ec1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 17 12 CoreFoundation 0x0000000101831792 __CFRunLoopDoSources0 + 242 13 CoreFoundation 0x000000010184d61f __CFRunLoopRun + 767 14 CoreFoundation
0x000000010184cf33 CFRunLoopRunSpecific + 467 15 GraphicsServices
0x00000001039923a0 GSEventRunModal + 161 16 UIKit
0x0000000100251043 UIApplicationMain + 1010 17 Meal Plan Generator
0x0000000100001193 main + 115 18 libdyld.dylib
0x0000000101f1a5fd start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

No correct solution

OTHER TIPS

the error says you are trying to use the push option but your view controller does not have navigation controller. in your storyboard click on the first view that you are trying to push from then from the top menu in the editor section select embed and then select navigation controller. that error will go away. make sure your identifier is set in the storyboard for the segue as well. alternatively select the segue and change it to modal and then try and the app will compile.

Make sure your IBAction method is hooked up properly to your .h or .m file. You may have set the action and deleted the method, which would result in the the class being unable to respond to the selector.

You should add nextviewcontroller to hierarchy of controllers.

Select the view controller in Storyboard which has the button and select the 'Editor' menu and choose 'Embed In' and select 'Navigation Controller'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top