Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 which uses AudioSessionInitialize like this

AudioSessionInitialize(NULL, NULL, NULL, self);

where self here is a ViewController.

like image 547
Ali Avatar asked Jul 29 '11 02:07

Ali


2 Answers

  • Automatic Reference Counting - 3.2.4. Bridged casts

You should use __bridge cast for it.

AudioSessionInitialize(NULL, NULL, NULL, (__bridge void *)self);
like image 116
Kazuki Sakamoto Avatar answered Nov 09 '22 03:11

Kazuki Sakamoto


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);

like image 34
Joshua Weinberg Avatar answered Nov 09 '22 02:11

Joshua Weinberg