首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >参考目标C中的AudioToolbox错误

参考目标C中的AudioToolbox错误
EN

Stack Overflow用户
提问于 2009-03-25 23:31:57
回答 1查看 7.4K关注 0票数 6

我在一个简单的Roulett应用程序中得到了下面的错误,我正在尝试播放一些wav文件。我不知道这个错误意味着什么,因为代码中没有出现警告标志,而且我已经导入了

以下是错误:

未定义符号:

"_AudioServicesCreateSystemSoundID",引用于:-CustomPickerViewController playWinSound in CustomPickerViewController.o -CustomPickerViewController spin: in CustomPickerViewController.o "_AudioServicesPlaySystemSound",引用于: CustomPickerViewController.o -CustomPickerViewController spin:在CustomPickerViewController.o :符号未找到collect2: ld返回1个退出状态

"_AudioServicesCreateSystemSoundID",引用于:-CustomPickerViewController playWinSound in CustomPickerViewController.o -CustomPickerViewController spin: in CustomPickerViewController.o "_AudioServicesPlaySystemSound",引用于: CustomPickerViewController.o -CustomPickerViewController spin:在CustomPickerViewController.o :符号未找到collect2: ld返回1个退出状态

这是密码:

代码语言:javascript
复制
#import "CustomPickerViewController.h"
#import <AudioToolbox/AudioToolbox.h>

@implementation CustomPickerViewController
@synthesize picker;
@synthesize winLabel;
@synthesize column1;
@synthesize column2;
@synthesize column3;
@synthesize column4;
@synthesize column5;
@synthesize button;

- (void)showButton
{
    button.hidden = NO;
}

-(void)playWinSound
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"win" ofType:@"wav"];
    SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
    AudioServicesPlaySystemSound (soundID);     
    winLabel.text = @"WIN!";
    [self performSelector:@selector(showButton) withObject:nil afterDelay:1.5];
}



-(IBAction)spin:(id)sender
{
    BOOL win = NO;
    int numInRow = 1;
    int lastVal = -1;
    for (int i = 0; i < 5; i++)
    {
        int newValue =random() % [self.column1 count];

        if (newValue == lastVal)
            numInRow++;
        else
            numInRow = 1;

        lastVal = newValue;
        [picker selectRow:newValue inComponent:i animated: YES];
        [picker reloadComponent:i];
        if (numInRow >= 3)
            win = YES;
    }

    button.hidden = YES;
    NSString *path = [[NSBundle mainBundle] pathForResource:@"crunch"ofType:@"wav"];
    SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((CFURLRef) [NSURL fileURLWithPath:path], &soundID);
    AudioServicesPlaySystemSound(soundID);

    if (win)
        [self performSelector:@selector(playWinSound) withObject: nil afterDelay: .5];
    else 
        [self performSelector:@selector(showButton) withObject: nil afterDelay: .5];

    winLabel.text = @"";
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-03-25 23:51:34

找到了。意识到我没有在AudioToolbox.Framework中导入框架XCode。:)

票数 25
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/683940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档