Re: Notification on network config change
Re: Notification on network config change
- Subject: Re: Notification on network config change
- From: email@hidden
- Date: Fri, 25 Feb 2005 01:16:34 -0600
I am trying to write either an application with LSBackgroundOnly set to
1 or a daemon that watches for an IP address change.
In an normal non-background application, in awakeFromNib, I have:
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
selector:@selector(networkChange:)
name:@"com.apple.system.config.network_change" object:nil];
I see "Feb 25 00:04:44 localhost configd[86]: posting notification
com.apple.system.config.network_change" in system.log whenever I change
my network settings, but the notification does not seem to get sent to
the distributed notification center or my application.
I had heard that this was a notification that was sent to the
distributed notification center and that's why I tried it. Is what Nick
describes (in the quote below) what I want to do? Any pointers on doing
that?
Thanks!
Steve
Patrice Goetghebeur wrote:
> I would need to get a cocoa notification when the network config has
> changed.
>
> I've read the Apple technote on that page:
> http://developer.apple.com/technotes/tn/tn1145.html where they show
a
> SCF function to get notified on IPv4 changes, but I'm a little
confuse
> how to get a NSNotication from that.... (especially how to initialise
> the parameters).
You have to use SystemConfiguration to create a dynamic store, set a
callback that gets called under the conditions you want, and plug that
dynamic store into the run loop. Then, in the callback, you can have it
post a notification to the notification center.
Last time I had to do this, there was sample code on
<http://developer.apple.com/> that shows how to do this, but you need
to search around for it...
Nick Zitzmann
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden