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 6670523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:16:45+00:00 2026-05-26T03:16:45+00:00

I need to communicate between two different console apps, Observer and Client. In the

  • 0

I need to communicate between two different console apps, Observer and Client.

In the Observer app I added this code:

[[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:self];

In the Client app I added this code:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(trackNotification:) name:@"MyNotification" object:nil];

-(void)trackNotification:(NSNotification*)notif
{
    NSLog(@"trackNotification: %@", notif);
    NSLog(@"trackNotification name: %@", [notif name]);
    NSLog(@"trackNotification object: %@", [notif object]);
    NSLog(@"trackNotification userInfo: %@", [notif userInfo]);
}

but nothing happens. I read all the documentation, but I am brand new in Mac OS X.
Any ideas?


I read about the Distributed Notifications, I changed my code and now looks like this:
In the server side:

[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(trackNotification:) name:@"MyNotification" object:nil];

-(void)trackNotification:(NSNotification*)notif
{
    NSLog(@"trackNotification: %@", notif);
    NSLog(@"trackNotification name: %@", [notif name]);
    NSLog(@"trackNotification object: %@", [notif object]);
    NSLog(@"trackNotification userInfo: %@", [notif userInfo]);
}

In the client side:

NSMutableDictionary *info;
info = [NSMutableDictionary dictionary];
[info setObject:@"foo" forKey:@"bar"];

[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MyNotification"
                                   object:nil
                                 userInfo:info 
                       deliverImmediately:YES];

I run both applications, but nothing happens. What am I doing wrong?

  • 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-05-26T03:16:46+00:00Added an answer on May 26, 2026 at 3:16 am

    I solved my problem. This is the source code:
    In the client side:

    NSDictionary *user = [NSDictionary dictionaryWithObjectsAndKeys: @"John Doe", @"name", @"22222222222", @"phone", @"Dummy address", @"address", nil];
    
    //Post the notification
    NSString *observedObject = @"com.test.net";
    NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter];
    [center postNotificationName: @"Plugin Notification" object: observedObject userInfo: user deliverImmediately: YES];
    

    In the server side

    NSString *observedObject = @"com.test.net";
    NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter];
    [center addObserver: self selector: @selector(receiveNotification:) name: @"Plugin Notification" object: observedObject];
    

    receiveNotification definition

    -(void)receiveNotification:(NSNotification*)notif
    {
        NSlog(@"Hello");
    }
    

    In dealloc method

    [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name: @"Plugin Notification" object: nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to communicate between server/client. I saw that CORBA is used for different
I have a scenario where I need a desktop console app to communicate with
I need to communicate between a Java app (desktop) and an iOS app. I've
I need to be able to communicate between two applications that reside on the
On my page I have n-userControls (same control) I need to communicate between them(to
I need to communicate with an XML-RPC server from a .NET 2.0 client. Can
I'm writing some code where the UI thread need to communicate with the background
I need to figure out how to communicate between ViewModels. I'm new to MVVM
I'm using .NET RIA Services July Preview to communicate between my Silverlight client and
I'm designing a communication protocol that will be used to communicate between two PC

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.