Using SCNetworkReachability callbacks in Objective-C app
Using SCNetworkReachability callbacks in Objective-C app
- Subject: Using SCNetworkReachability callbacks in Objective-C app
- From: Paul Borokhov <email@hidden>
- Date: Wed, 26 Dec 2007 00:25:37 -0800
Hope someone here will be able to help me out...
I have a regular Objective-C/Cocoa app. In my main Controller class, I have instance variables
Boolean isReachable;
SCNetworkReachabilityRef facebookName;
In my application initialization code I have
facebookName = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [@"www.facebook.com" cStringUsingEncoding:NSISOLatin1StringEncoding]);
if (SCNetworkReachabilitySetCallback(facebookName, networkStatusDidChange, NULL) &&
SCNetworkReachabilityScheduleWithRunLoop(facebookName, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) {
CFRunLoopRun();
}
Then, here's the callback function:
void networkStatusDidChange(SCNetworkReachabilityRef name, SCNetworkConnectionFlags flags, void * infoDictionary) {
if (name != NULL) {
if (flags != kSCNetworkFlagsReachable) {
isReachable = NO;
} else {
isReachable = YES;
}
}
}
However, this code won't work due to a compile-time error at the lines where I try to set isReachable: error: 'isReachable' was not declared in this scope.
What am I doing wrong here?
Thanks and happy holidays!
Paul
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden