0

嗨,我已经创建了一个 Xcode 音板,但是当我在我的 iPhone 上运行它时,我得到了这个错误,不知道如何解决它,你能帮忙吗?

//
//  main.m
//  sound
//
//  Created by Paul masters on 27/04/2012.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

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

错误是

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

线程 1:信号 SIGABRT

谢谢

这是视图控制器.h

#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>

@interface ViewController : UIViewController
- (IBAction)yooo:(id)sender;

- (IBAction)boom:(id)sender;


@end

这是视图控制器.m

- (IBAction)yooo:(id)sender {

    CFBundleRef mainbundle = CFBundleGetMainBundle();
    CFURLRef soundFileUrlRef;
    soundFileUrlRef = CFBundleCopyResourceURL(mainbundle, (CFStringRef) @"tb1", CFSTR ("wav"), NULL); 
    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileUrlRef, &soundID);
    AudioServicesPlaySystemSound(soundID);}

- (IBAction)boom:(id)sender {


    CFBundleRef mainbundle = CFBundleGetMainBundle();
    CFURLRef soundFileUrlRef;
    soundFileUrlRef = CFBundleCopyResourceURL(mainbundle, (CFStringRef) @"ta1", CFSTR ("wav"), NULL); 
    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileUrlRef, &soundID);
    AudioServicesPlaySystemSound(soundID);
}


@end

这是我的代码与那个线程 1 错误! 这是我的代码失败的图像

在此处输入图像描述

4

2 回答 2

1

您需要做的是找到构建阶段,然后单击 + 并添加audio.framework ,然后尝试run and build,一切都应该很好。

于 2012-06-12T12:51:25.553 回答
0

您需要设置一个异常断点。请参阅Xcode 4 中的“运行 > 在 Objective-C 异常上停止”?. 如果你没有异常断点并且发生了异常,那么你将看到的只是一个没有堆栈的 SIGABRT,所以你无法找出到底发生了什么。

于 2012-04-27T11:25:02.680 回答