Objective-C Convert SCNetworkReachabilityContext ARC

When converting an application to use automatic reference counting, I encountered this error:

SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL}; 

Implicit conversion of an Objective-C pointer to 'void *' is prohibited by ARC

This fixes the compiler error, but gives a warning:

 SCNetworkReachabilityContext context = {0, objc_unretainedPointer(self), NULL, NULL, NULL}; 

How to get rid of this warning?

Initializing 'void *' with an expression of type 'objc_objectptr_t' (aka 'const void *') discards the qualifiers

+4
source share
1 answer

You should be able to independently (id) in void * without any problems.

 SCNetworkReachabilityContext context = {0, ( void * )self, NULL, NULL, NULL}; 
+7
source

All Articles