Question

My app was working fine this morning. I updated to Xcode 5.1 and when I run my app, it crashes when I hit play. My app has a modal button that leads to another view controller. The first view controller is the main screen. I start the app, press the play button, then it does nothing for about a second (instead of taking me to the second view controller, which is the game itself), and then Xcode takes me to the main.m. This is what my main.m looks like (have not modified it). So, when Xcode takes me here, the line that starts with return UIApplicationMain is highlighted in green and on the far right it says thread 1: signal SIGABRT

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

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

Does anyone have a suggestion about what is going on?

------updated

I am not sure if this helps (because I'm still a beginner, but i think this is it). it says:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter' *** First throw call stack:

(
    0   CoreFoundation                      0x01f0c1e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0180a8e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01f0bfbb +[NSException raise:format:] + 139
    3   Foundation                          0x0142692b -[NSURL(NSURL) initFileURLWithPath:] + 123
    4   Foundation                          0x014267fd +[NSURL(NSURL) fileURLWithPath:] + 67
    5   Bad Jetpack Complete                0x00004f92 -[Game viewDidLoad] + 1170
    6   UIKit                               0x005e933d -[UIViewController loadViewIfRequired] + 696
    7   UIKit                               0x005e95d9 -[UIViewController view] + 35
    8   UIKit                               0x005f8f89 -[UIViewController shouldAutorotate] + 36
    9   UIKit                               0x005f92d1 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297
    10  UIKit                               0x008973d5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
    11  UIKit                               0x005f55d5 -[UIViewController presentViewController:withTransition:completion:] + 6538
    12  UIKit                               0x005f5aef -[UIViewController presentViewController:animated:completion:] + 130
    13  UIKit                               0x005f5b2f -[UIViewController presentModalViewController:animated:] + 56
    14  UIKit                               0x00a3fe00 -[UIStoryboardModalSegue perform] + 271
    15  UIKit                               0x00a2ef0c -[UIStoryboardSegueTemplate _perform:] + 174
    16  UIKit                               0x00a2ef87 -[UIStoryboardSegueTemplate perform:] + 115
    17  libobjc.A.dylib                     0x0181c880 -[NSObject performSelector:withObject:withObject:] + 77
    18  UIKit                               0x004cc3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
    19  UIKit                               0x004cc345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    20  UIKit                               0x005cdbd1 -[UIControl sendAction:to:forEvent:] + 66
    21  UIKit                               0x005cdfc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
    22  UIKit                               0x005cd243 -[UIControl touchesEnded:withEvent:] + 641
    23  UIKit                               0x0050bddd -[UIWindow _sendTouchesForEvent:] + 852
    24  UIKit                               0x0050c9d1 -[UIWindow sendEvent:] + 1117
    25  UIKit                               0x004de5f2 -[UIApplication sendEvent:] + 242
    26  UIKit                               0x004c8353 _UIApplicationHandleEventQueue + 11455
    27  CoreFoundation                      0x01e9577f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    28  CoreFoundation                      0x01e9510b __CFRunLoopDoSources0 + 235
    29  CoreFoundation                      0x01eb21ae __CFRunLoopRun + 910
    30  CoreFoundation                      0x01eb19d3 CFRunLoopRunSpecific + 467
    31  CoreFoundation                      0x01eb17eb CFRunLoopRunInMode + 123
    32  GraphicsServices                    0x030885ee GSEventRunModal + 192
    33  GraphicsServices                    0x0308842b GSEventRun + 104
    34  UIKit                               0x004caf9b UIApplicationMain + 1225
    35  Bad Jetpack Complete                0x00002e7d main + 141
    36  libdyld.dylib                       0x03c7f701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

- (void)viewDidLoad

{

CactusTop.hidden = YES;
CactusBottom.hidden = YES;

ScoreLabel.hidden = YES;
GameOverScreen.hidden = YES;
RestartButton.hidden = YES;
LeaderBoardButton.hidden = YES;
ScoreLabel2.hidden = YES;
HighscoreLabel.hidden = YES;
RestartButton.hidden = YES;

HighScoreNumber = [[NSUserDefaults standardUserDefaults] integerForKey:@"HighScoreSaved"];

NSURL *ClickURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]  pathForResource:@"Click"ofType:@"mp3"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)ClickURL, &  ClickSound);


NSURL *ExplosionURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Explosion" ofType:@"mp3"]];
ExplosionSound = [[AVAudioPlayer alloc] initWithContentsOfURL:ExplosionURL error:nil];
[ExplosionSound setNumberOfLoops:0];
[ExplosionSound prepareToPlay];

NSURL *JetpackURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Jetpack 1_2sec_01c" ofType:@"mp3"]];
JetpackSound = [[AVAudioPlayer alloc] initWithContentsOfURL:JetpackURL error:nil];
[JetpackSound setNumberOfLoops:0];
[JetpackSound prepareToPlay];

NSURL *PointURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Point" ofType:@"mp3"]];
PointSound = [[AVAudioPlayer alloc] initWithContentsOfURL:PointURL error:nil];
[PointSound setNumberOfLoops:0];
[PointSound prepareToPlay];

this is the updated question with the view did load

Was it helpful?

Solution

OK, somewhere in your app you are trying to load a file from a URL but the URL is nil.

Can you show the code where you are doing this. It will help answer you question.

Actually, it's in the file Game.m in the method - (void)viewDidLoad;.

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