Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

iphone - reachabilityWithHostName Example

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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");
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...