1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#import "Connexioncontroller.h"
@implementation Connexioncontroller
@synthesize Reachability;
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:[self handleNetworkChange] name:kReachabilityChangedNotification object:nil];
//error: No visible @interface for 'connexioncontroller' declares the selector 'handleNetworkchange'
reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
if(remoteHostStatus == NotReachable)
{
NSLog(@"no");
}
else if (remoteHostStatus == ReachableViaWiFi)
{
NSLog(@"wifi");
}
else if (remoteHostStatus == ReachableViaWWAN)
{
NSLog(@"cell");
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void) handleNetworkChange:(NSNotification *)notice
{
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
if(remoteHostStatus == NotReachable)
{
NSLog(@"no");
}
else if (remoteHostStatus == ReachableViaWiFi)
{
NSLog(@"wifi");
}
else if (remoteHostStatus == ReachableViaWWAN)
{
NSLog(@"cell");
}
}
@end |