implicit conversion of an Objective-C pointer to &

2019-03-08 07:40发布

What does this mean and what alternative do I have?

implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC

I am porting an Xcode3 project to iOS5 wich uses AudioSessionInitialize like this

AudioSessionInitialize(NULL, NULL, NULL, self);

where self here is a ViewController.

2条回答
smile是对你的礼貌
2楼-- · 2019-03-08 08:03

You can't do implicit casts to void* anymore, AudioSessionInitialize(NULL, NULL, NULL, objc_unretainedPointer(self)); should do the trick.

EDIT: Historical point, the answer above was from before the __bridge casts were finalized. In modern code the correct answer is that provided by @KazukiSakamoto, AudioSessionInitialize(NULL, NULL, NULL, (__bridge void*)self);

查看更多
▲ chillily
3楼-- · 2019-03-08 08:04

You should use __bridge cast for it.

AudioSessionInitialize(NULL, NULL, NULL, (__bridge void *)self);
查看更多
登录 后发表回答