C SCNetworkReachabilityContext ARC conversion

While converting an app to use Automatic Reference Counting I came across this error:

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

Implicit conversion of an Objective-C pointer to 'void *' is disallowed with 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 qualifiers


你应该能够将自己(id)投给void *而没有问题。

SCNetworkReachabilityContext context = {0, ( void * )self, NULL, NULL, NULL};
链接地址: http://www.djcxy.com/p/44902.html

上一篇: &自我类型转换导致编译器错误

下一篇: C SCNetworkReachabilityContext ARC转换