开发者

Objective-C SCNetworkReachabilityContext ARC conversion

开发者 https://www.devze.com 2023-03-30 01:59 出处:网络
While converting an app开发者_开发百科 to use Automatic Reference Counting I came across this error:

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


You should be able to cast self (id) to a void * without problem.

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号