【问题标题】:Referencing Error to the AudioToolbox in Objective C在 Objective C 中引用 AudioToolbox 的错误
【发布时间】:2010-10-15 14:21:42
【问题描述】:

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

这是错误:

未定义的符号:
"_AudioServicesCreateSystemSoundID", 参考自: -[CustomPickerViewController playWinSound] 中 CustomPickerViewController.o -[CustomPickerViewController spin:] 在 CustomPickerViewController.o "_AudioServicesPlaySystemSound", 参考自: -[CustomPickerViewController playWinSound] 中 CustomPickerViewController.o -[CustomPickerViewController spin:] 在 CustomPickerViewController.o ld:未找到符号 collect2:ld 返回 1 个退出状态
"_AudioServicesCreateSystemSoundID", 参考自: -[CustomPickerViewController playWinSound] 中 CustomPickerViewController.o -[CustomPickerViewController spin:] 在 CustomPickerViewController.o "_AudioServicesPlaySystemSound", 参考自: -[CustomPickerViewController playWinSound] 中 CustomPickerViewController.o -[CustomPickerViewController spin:] 在 CustomPickerViewController.o ld:未找到符号 collect2:ld 返回 1 个退出状态

这里是代码:

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

【问题讨论】:

    标签: objective-c


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多