xcode 4.2音板线程1

时间:2012-04-27 10:17:23

标签: iphone xcode ios5

嗨我已经创建了一个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

感谢

这是视图controller.h

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

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

- (IBAction)boom:(id)sender;


@end

这是视图controller.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错误!! here is a image of my code that failed

enter image description here

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

您需要设置异常断点。见"Run > Stop on Objective-C exception" in Xcode 4?。如果您没有异常断点并且发生异常,那么您将看到的只是一个没有堆栈的SIGABRT,因此您无法找到真正发生的事情。