当前位置:  开发笔记 > IOS > 正文

在Objective C中引用AudioToolbox的错误

如何解决《在ObjectiveC中引用AudioToolbox的错误》经验,为你挑选了1个好方法。

我在一个简单的Roulett应用程序中遇到以下错误,我正在尝试播放一些wav文件.我不确定错误是什么意思,因为代码中没有警告标志,我已经导入了

这是错误:

未定义的符号:
"_ AudioServicesCreateSystemSoundID",引自: - CustomPickerViewController.o中的[CustomPickerViewController playWinSound] - CustomPickerViewController.o中的[CustomPickerViewController spin:]"_ AudioAvicesServicesSystemSound",引用自: - CustomPickerViewController.o中的[CustomPickerViewController playWinSound] - [CustomPickerViewController spin: ]在CustomPickerViewController.o ld:未找到符号collect2:ld返回1退出状态
"_AudioServicesCreateSystemSoundID",引自: - CustomPickerViewController.o中的[CustomPickerViewController playWinSound] - CustomPickerViewController.o中的[CustomPickerViewController spin:]"_AudioServicesPlaySystemSound",引自: - CustomPickerViewController.o中的[CustomPickerViewController playWinSound] - CustomPickerViewController.o中的[CustomPickerViewController spin:] ld:找不到符号collect2:ld返回1退出状态

以下是代码:

#import "CustomPickerViewController.h"
#import 

@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 = @"";
}

Craig.. 25

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



1> Craig..:

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

推荐阅读
谢谢巷议
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有