此代码怎么了?我以前用过它,但是现在我收到了这些警告...

警告:从不兼容的指针类型中传递“ AudioServicesCreatesystemsoundid”的参数2

警告:传递“ AudioServicesPlaysystemsound”的参数1使指针无需演员。

-(void)playfireSound{

    NSString *path = [[NSBundle mainBundle] pathForResource:@"fireSound" ofType:@"wav"];
    NSURL *url = [NSURL fileURLWithPath:path];
    AudioServicesCreateSystemSoundID((CFURLRef) url, &fireSound);   
    AudioServicesPlaySystemSound(fireSound);
}
有帮助吗?

解决方案

您对射击变量的声明可能不正确用于此API。也许您将其声明为某种对象,而不是systemsoundID,该对象为int type int。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top