gpt4 book ai didi

ios - Apple Mach-O链接器错误 “_AudioServicesCreateSystemSound”和另外1个

转载 作者:行者123 更新时间:2023-12-03 02:11:00 29 4
gpt4 key购买 nike

我是iOS开发的新手,遇到了这个错误。我只是在项目中添加声音,并且已经导入了AudioToolbox.Framework,但是当我尝试构建项目时,它给了我上面的错误。它还给了我“Apple Mach-O Linker Error _AudioServicesDisposeSystemSoundID”和“Linker命令失败,退出代码为1(使用-v查看调用”。

这是我的代码:

CurrentLocationViewController.m

@implementation CurrentLocationViewController {
CLLocationManager *locationManager;
CLLocation *location;
BOOL updatingLocation;
NSError *lastLocationError;
CLGeocoder *geocoder;
CLPlacemark *placemark;
BOOL performingReverseGeocoding;
NSError *lastGeocodingError;
UIActivityIndicatorView *spinner;
SystemSoundID soundID;
}

和:
- (void)viewDidLoad
{
[super viewDidLoad];
[self updateLabels];
[self configureGetButton];
[self loadSoundEffect];
}

也:
        lastGeocodingError = error;
if (error == nil && [placemarks count] > 0) {
if (placemark == nil) {
NSLog(@"First Time!");
[self playSoundEffect];
}
placemark = [placemarks lastObject];
} else {
placemark = nil;
}

最后:
#pragma mark - Sound Effect

- (void)loadSoundEffect
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"Sound.caf" ofType:nil];

NSURL *fileURL = [NSURL fileURLWithPath:path isDirectory:NO];
if (fileURL == nil) {
NSLog(@"NSURL is nil for file file path: %@", path);
return;
}

OSStatus error = AudioServicesCreateSystemSound((__bridge CFURLRef)fileURL,&soundID);

if (error != kAudioServicesNoError) {
NSLog(@"Error code %ld loading sound at path: %@", error, path);
return;
}
}

- (void)unloadSoundEffect
{
AudioSystemDisposeSystemSoundID(soundID);
soundID = 0;
}

- (void)playSoundEffect
{
AudioServicesPlaySystemSound(soundID);
}

@end

当我调用AudioSystem / Services时,在行上有一个黄色警告,提示“函数'(该行的内容)的隐式声明在C99中无效”

任何帮助将不胜感激!谢谢!

最佳答案

AudioServicesCreateSystemSound更改为AudioServicesCreateSystemSoundID

关于ios - Apple Mach-O链接器错误 “_AudioServicesCreateSystemSound”和另外1个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23999605/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com