线程1程序收到信号SIGABRT

发布于 2024-12-15 01:16:43 字数 967 浏览 2 评论 0原文

#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) 

这就是输出框告诉我的。

#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;
}

When I run it on my device it gives me the following error:

Thread 1:Program received signal: "SIGABRT".

How do i fix this?

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) 

That is what the output box tells me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

春花秋月 2024-12-22 01:16:43

在代码中的某个位置您使用

[NSURL initFileURLWithPath:]

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

Somewhere in your code you use

[NSURL initFileURLWithPath:]

but you pass a nil path value.
Check your string.

垂暮老矣 2024-12-22 01:16:43

您的路径在设备上为零。

首先,尝试清理您的项目。

在此处输入图像描述

然后,确保在“复制捆绑资源”构建阶段复制文件

在此处输入图像描述

正如安娜·卡列尼娜所建议的,确保以区分大小写的方式处理名称。

Your path is nil on the device.

First, try cleaning your project.

enter image description here

Then, ensure the files are being copied over in the "Copy Bundle Resources" build phase

enter image description here

And as Anna Karenina suggested, make sure the names are being handled in a case sensitive manner.

请别遗忘我 2024-12-22 01:16:43
- (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];
}
- (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];
}
辞旧 2024-12-22 01:16:43

重要的错误是 'NSInvalidArgumentException',正如错误所述,问题在于其中一个字符串不应该为 null。根据您想要执行的操作,这篇文章可能会有所帮助:正确使用 UIApplicationMain

The important error is 'NSInvalidArgumentException', and as the error says, the problem is that one of the strings is null that shouldn't be. Depending on what you're trying to do, this post may be of help: Proper use of UIApplicationMain

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文