AudioServices.h not found in objective-C iOS project that includes AudioToolbox framework

╄→гoц情女王★ 提交于 2019-12-05 13:19:05

The problem is that the system can't cast self to void * automatically when you're using ARC. Self is used in the last parameter of AudioSessionInitialize function (and others).

You need to tell ARC how the ownership of the memory is controlled by manually casting it to void * using __bridge. This says 'Don't change ownership of the memory'.

So change self to (__bridge void *)self in the calls to the AudioSession functions.

e.g.

OSStatus error = AudioSessionInitialize(NULL, NULL, interruptionListener, (__bridge void*)self);

try "#import <AudioToolbox/AudioServices.h>" and see if your problem disappears.

The < and > characters make a difference. Using double quotes in an "#import" implies you want the compiler to search for "user headers", where the angled brackets imply you want the compiler to search in system frameworks.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!