Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7919265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:48:38+00:00 2026-06-03T15:48:38+00:00

When my class initializes, it adds itself as an observer for a bunch of

  • 0

When my class initializes, it adds itself as an observer for a bunch of different Wi-Fi notifications. For some reason, the selector isn’t running when any of these things happen. Any ideas? Thank you ahead of time.

-(id) init
{
    if (self)
    {
        sself = self;
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWModeDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWSSIDDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWBSSIDDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWCountryCodeDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWLinkDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWPowerDidChangeNotification object:nil];

UPDATE:
Here is the handleNotification method:

-(void) handleNotification:(NSNotification*) notification
{
    NSLog(@"Notification Received");
}

I have included the CoreWLAN framework to my project:
enter image description here

I’ve downloaded CoreWLANWirelessManager.app, and this is what I’m using for reference. Oddly enough, Apple’s code is using deprecated notifications, and it still works. I’ve tried using the new API’s and the deprecated API’s with no success. I’m not sure if I can post their code here, but there is literally no difference. The selector even has the same name.

Please don’t hesitate to ask for further elaboration.

UPDATE (After Dustin’s answer): I’ve created a new project in hopes to isolate the issue. I set up my .h and .m files just as you described. Sadly, I’m still not getting any notifications. To show you I’m not lying (or crazy), I’ve included two (fairly crowded) screenshots that were taken during the same runtime. Notice:
(1. I have a breakpoint in the handleNotification: method. The app never pauses.
(2. I included the network window to show my Mac has indeed changed Wi-Fi networks during this runtime.
(3. Nothing is NSLoged

Network 1:
enter image description here

Network 2:
enter image description here

UPDATE May 17, 2012: Dustin’s answer was correct, but the Wi-Fi interface name varies depending on what hardware the app is running on. In my case, (MacBook Air; no ethernet), my Wi-Fi is en0 instead of en1. I managed to grab the system configuration plst file off my moms iMac, and the Wi-Fi is called en1. Ethernet is en0. Thank you all for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:48:40+00:00Added an answer on June 3, 2026 at 3:48 pm

    In order for you to get those notifications you need to be holding on to an instance of CWInterface. Your .h would look like this

    #import <Cocoa/Cocoa.h>
    @class CWInterface;
    
    @interface AppDelegate : NSObject <NSApplicationDelegate>
    
    @property (assign) IBOutlet NSWindow *window;
    @property (retain) CWInterface *wirelessInterface;
    
    @end
    

    Then in your .m file would look like this

    #import "AppDelegate.h"
    #import <CoreWLAN/CoreWLAN.h>
    
    @implementation AppDelegate
    
    @synthesize window = _window;
    @synthesize wirelessInterface;
    
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
        // Insert code here to initialize your application
    
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWModeDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWSSIDDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWBSSIDDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWCountryCodeDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWLinkDidChangeNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:CWPowerDidChangeNotification object:nil];
    
        self.wirelessInterface = [CWInterface interfaceWithName:@"en1"];
    }
    
    
    -(void) handleNotification:(NSNotification*) notification
    {
        NSLog(@"Notification Received");
    }
    
    @end
    

    Notice the CWInterface property, that’s the important bit

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some iPhone SDK 4.0 code which initializes an NSOperationQueue and then adds
I was wondering, how can I make jquery UI not to adds any class
I want to create a class that initializes a timer which will be used
class Observer def initialize(&block) instance_eval(&block) if block_given? end end I'm wondering what assumption is
Here is some code: class Person def initialize(age) @age = age end def age
Which static class initializes first if we have one more static classes in our
Suppose I have a simple class that Adds: public class Multiply { public int
I've got a method that creates some Foo and adds it to a vector
I can't figure out the proper block initialize class Foo attr_accessor :bar end obj
I would like to know: how can i initialize class object with parameters? I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.