- (
BOOL
)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged:)
name: kReachabilityChangedNotification
object: nil];
hostReach =[[Reachability reachabilityWithHostName:@
"www.google.com"
] retain];
[hostReach startNotifier];
[self updateInterfaceWithReachability: hostReach];
}
- (
void
)reachabilityChanged: (NSNotification*)note
{
Reachability*curReach = [note object];
NSParameterAssert([curReach isKindOfClass:[Reachability
class
]]);
[self updateInterfaceWithReachability:curReach];
}
- (
void
)updateInterfaceWithReachability: (Reachability*)curReach
{
NetworkStatus status=[curReach currentReachabilityStatus];
if
(status== NotReachable) {
UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@
"MyApp Name"
message:@
"NotReachable"
delegate:nil
cancelButtonTitle:@
"YES"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}