reachabilityWithHostName Example

2020-02-15 06:25发布

问题:

i read the https://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html my Question is if the www.apple.com is become not active Suddenly..this code will alert me? or just if my connection fail's?

回答1:

That's absolutely right.

It will fire off a kReachabilityChangedNotification notification that tells you the new reachability state.

You get the new reachability state something like this :

- (void)reachabilityChanged:(NSNotification *)notification {
    Reachability *reachability = notification.object;

    if (NotReachable == reachability.currentReachabilityStatus)
        NSLog(@"No longer reachable");
}