由于未捕获的异常而终止应用程序。 " nil字符串参数"

时间:2014-03-31 00:19:25

标签: ios objective-c crash viewdidload xcode5.1

今天早上我的应用程序工作正常。我更新到Xcode 5.1,当我运行我的应用程序时,它在我玩游戏时崩溃了。我的应用程序有一个模式按钮,通向另一个视图控制器。第一个视图控制器是主屏幕。我启动应用程序,按下播放按钮,然后大约一秒钟没有做任何事情(而不是带我到第二个视图控制器,这是游戏本身),然后Xcode将我带到main.m.这是我的main.m看起来像(没有修改它)。因此,当Xcode将我带到此处时,以return UIApplicationMain开头的行以绿色突出显示,而在最右侧则显示主题1:信号SIGABRT

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

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

有没有人对发生的事情有什么建议?

------更新

我不确定这是否有帮助(因为我还是初学者,但我认为就是这样)。它说:

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];

这是更新的问题,视图已加载

1 个答案:

答案 0 :(得分:4)

好的,在您的应用中的某个位置,您尝试从网址加载文件,但网址为零。

您能否显示执行此操作的代码?它将有助于回答你的问题。

实际上,它位于Game.m方法的- (void)viewDidLoad;文件中。