?????????????iOS?????????????wifi?????????(Reeder)???????????????????????????(Evernote)????????????Reachability???????????
????д????????
???????Reachability????????
???????3?????繃??
????2G/3G
????wifi
??????????
????????????
????????controller
???????controller
???????????:
????????wifi?????
????Reachability???
????Reachablity ?????iOS????iOS?豸???繃??????
?????????????????????
?????????????????????
?????????????????
???????
???????? network ??????network?????????demo??????????п??????????
???????Cocoaspod???????
?????????????? SystemConfiguration.framework ??
????????Reachability??????á??????????Supporting Files/networ-Prefix.pch??:
????#import <Reachability/Reachability.h>
????#import <Reachability/Reachability.h>
??????????????cocoaspod????????????:
????http://witcheryne.iteye.com/blog/1873221
???????
????stackoverflow??????????????????reachability???÷?
????http://stackoverflow.com/questions/11177066/how-to-use-ios-reachability
?????????????Reachability???ok???
???????Controller???????Reachability
????Block??????
- (void)viewDidLoad
{
[super viewDidLoad];
DLog(@"???? www.apple.com ????????");
Reachability* reach = [Reachability reachabilityWithHostname:@"www.apple.com"];
DLog(@"-- current status: %@"?? reach.currentReachabilityString);
// start the notifier which will cause the reachability object to retain itself!
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged:)
name:kReachabilityChangedNotification
object:nil];
reach.reachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue()?? ^{
self.blockLabel.text = @"???????";
self.blockLabel.backgroundColor = [UIColor greenColor];
});
};
reach.unreachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue()?? ^{
self.blockLabel.text = @"???粻????";
self.blockLabel.backgroundColor = [UIColor redColor];
});
};
[reach startNotifier];
}
- (void)viewDidLoad
{
[super viewDidLoad];
DLog(@"???? www.apple.com ????????");
Reachability* reach = [Reachability reachabilityWithHostname:@"www.apple.com"];
DLog(@"-- current status: %@"?? reach.currentReachabilityString);
// start the notifier which will cause the reachability object to retain itself!
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged:)
name:kReachabilityChangedNotification
object:nil];
reach.reachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue()?? ^{
self.blockLabel.text = @"???????";
self.blockLabel.backgroundColor = [UIColor greenColor];
});
};
reach.unreachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue()?? ^{
self.blockLabel.text = @"???粻????";
self.blockLabel.backgroundColor = [UIColor redColor];
});
};
[reach startNotifier];
}