iPhone Reachable classes

2019-05-19 22:15发布

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

2条回答
The star\"
2楼-- · 2019-05-19 22:44

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

查看更多
放我归山
3楼-- · 2019-05-19 22:45

Try this

NSCAssert([(__bridge NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
查看更多
登录 后发表回答