Notifications between Carbon and Cocoa

Discussion in 'Mac Programming' started by bermanmk, Feb 26, 2006.

  1. macrumors newbie

    Joined:
    Feb 26, 2006
    #1
    I'm writing a preference pane bundle in cocoa (using the xcode project defaults) and a carbon app that is supposed to communicate with it. However the notifications the cocoa app is posting either don't get sent or the carbon app is not registering correctly as an observer. I've hunted around on the web quite a bit and can't seem to see why this isn't working. The relevant bit in the cocoa panel bundle is :


    [[NSNotificationCenter defaultCenter] postNotificationName: @"IMStatusPanelUpdate" object:nil userInfo:nil deliverImmediately:TRUE];

    and the call in the carbon application that is supposed to set up the observer is:

    center = CFNotificationCenterGetLocalCenter();

    CFNotificationCenterAddObserver(center,
    NULL,
    updateMessages,
    CFSTR("IMStatusPanelUpdate"),
    NULL,
    CFNotificationSuspensionBehaviorDeliverImmediately);


    the updateMessages function prototype is copied right out of the example posted in the docs, so I'm assuming that it works. Also I tried adding the file "do_xnc_log" to /var/tmp which is supposed to log notifications, but I don't see anything there. Anyone have any ideas as to what is going wrong or a better way to debug notifications?
     
  2. macrumors 6502a

    csubear

    Joined:
    Aug 22, 2003
    #2
    i've never used the note center for ipc, but i think you should be using the NSDistributedNotificationCenter ?
     
  3. thread starter macrumors newbie

    Joined:
    Feb 26, 2006
    #3
    I've tried it with CFNotificationCenterGetDistributedCenter() as well with a similar lack of effect.
     
  4. thread starter macrumors newbie

    Joined:
    Feb 26, 2006
    #4
    oh, I see you meant the NSDistributedNotificationCenter, my bad. That totally worked. Thanks
     

Share This Page