Re: Using SCNetworkReachability callbacks in Objective-C app
Re: Using SCNetworkReachability callbacks in Objective-C app
- Subject: Re: Using SCNetworkReachability callbacks in Objective-C app
- From: Paul Borokhov <email@hidden>
- Date: Wed, 26 Dec 2007 00:58:41 -0800
oh. That's a bit of a "duh" moment.
As a quick a follow-up, is there any particular place this function should be in? Does it need to sit in its own file that will then have to be imported by the class, or can it just be in the class itself?
...I really wonder sometimes why Apple makes us deal with two separate programming paradigms to get things done...
Paul
----------Original Message----------
On 12/26/07 19:49 , David Symonds (email@hidden) wrote:
> On Dec 26, 2007 7:25 PM, Paul Borokhov <email@hidden> wrote:
>
>> 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?
>
> The callback function is a *function*, not a class's method. When this
> code runs, you're "outside" your controller class, so you'll need to
> call something on your controller class from this function to achieve
> what you want. That's what the infoDictionary is there for: so you can
> pass, say, a pointer to your controller object.
>
>
> Dave.
_______________________________________________
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