问题描述
这是什么意思,我有什么选择?
What does this mean and what alternative do I have?
implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC
我正在将Xcode3项目移植到iOS5,就像这样使用AudioSessionInitialize
I am porting an Xcode3 project to iOS5 wich uses AudioSessionInitialize like this
AudioSessionInitialize(NULL, NULL, NULL, self);
其中self
是一个ViewController.
where self
here is a ViewController.
推荐答案
您不能再对void*
进行隐式强制转换,AudioSessionInitialize(NULL, NULL, NULL, objc_unretainedPointer(self));
应该可以解决问题.
You can't do implicit casts to void*
anymore, AudioSessionInitialize(NULL, NULL, NULL, objc_unretainedPointer(self));
should do the trick.
从历史的角度来看,以上答案来自__bridge
强制转换完成之前.在现代代码中,正确答案是@KazukiSakamoto,AudioSessionInitialize(NULL, NULL, NULL, (__bridge void*)self);
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);
这篇关于ARC不允许将Objective-C指针隐式转换为"void *"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!