iPhone Reachable classes

时光总嘲笑我的痴心妄想 提交于 2019-12-10 11:04:43

问题


I have added the two files Reachability.h/m. The problem I am having is in the ReachabilityCallback method

NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");

The error message is: Cast of C pointer type 'void *' to Objective-C pointer type 'NSObject * requires a bridged cast

NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];

Error: 'NSAutoreleasePool' is unavailable: not available in automatic reference counting mode

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

Error: Implicit conversion of an Object-C pointer to 'void *' is disallowed with ARC

There is a bunch of ARC forbids explicit message send of 'release'/'autorelease'.

Is there a version of the code that will work for ARC?

Thanks


回答1:


Try this

NSCAssert([(__bridge NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");



回答2:


Try tonymillion's Reachability classes, they're ARC and GCD compatible.



来源:https://stackoverflow.com/questions/11945024/iphone-reachable-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!