线程1程序收到信号SIGABRT

时间:2011-11-10 20:01:07

标签: iphone ios4 memory error-handling compiler-errors

#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}

当我在我的设备上运行它时,它会给我以下错误:

  

线程1:编程接收信号:“SIGABRT”。

我该如何解决这个问题?

2011-11-10 14:59:43.487 AVMultiPlayer[13554:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(0x3102a8bf 0x381cf1e5 0x3102a7b9 0x3102a7db 0x3803e06f 0x3803e00b 0x2dc9 0x2b5d 0x30f84435 0x32fdf9eb 0x32fdf9a7 0x32fdf985 0x32fdf6f5 0x32fdf321 0x32fde485 0x32fddf01 0x32fc44ed 0x32fc3d2d 0x33bafe13 0x30ffe553 0x30ffe4f5 0x30ffd343 0x30f804dd 0x30f803a5 0x33baefed 0x32ff2743 0x25b5 0x2574)
terminate called throwing an exception(gdb) 

这就是输出框告诉我的。

4 个答案:

答案 0 :(得分:2)

您的代码中某处使用

[NSURL initFileURLWithPath:]

但是你传递了一个零路径值 检查你的字符串。

答案 1 :(得分:1)

您的路径在设备上为零。

首先,尝试清理项目。

enter image description here

然后,确保在“复制包资源”构建阶段

中复制文件

enter image description here

正如Anna Karenina建议的那样,确保以区分大小写的方式处理名称。

答案 2 :(得分:0)

- (void)playOnce:(NSString )aSound {    // <-- Write NSString* here. Check it, it may be null

    // or "aSound".caf is not include in your project or is just not checked to be part of your project (remove it and add it again)
    NSString *path = [[NSBundle mainBundle] pathForResource:aSound ofType:@"caf"];
    AVAudioPlayer theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; 

   [theAudio setDelegate: self]; 
   [theAudio setNumberOfLoops:0]; 
   [theAudio setVolume:1.0]; 
   [theAudio play];
}

答案 3 :(得分:0)

重要的错误是'NSInvalidArgumentException',正如错误所说,问题是其中一个字符串是null,不应该是。根据您要执行的操作,此帖子可能有所帮助:Proper use of UIApplicationMain