Hi,

I am trying to use NSDistributedNotificationCenter to send a notification to a listener application. I am stuck since I do not know what to pass to the AddObserverSelectorNameObject() function. I could not find an example or more info on how to use this function. Here is my code (which fails to compile) :

using System;
using System.Collections.Generic;
using System.Text;

using Monobjc;
using Monobjc.Cocoa;

namespace ipc_listener
{
   class Program : NSObject
   {
       private static Listener l = null;

       static void Main(string[] args)
       {
           ObjectiveCRuntime.LoadFramework("Cocoa");
           ObjectiveCRuntime.Initialize();
           NSApplication.Initialize();

           l = new Listener();
           l.run();

           NSApplication.RunApplication();
       }
   }

   class Listener : NSObject
   {
       private NSNotificationCenter nc = null;
       private delegate void NotificationHandler(NSNotification n);

       public void run()
       {
           nc = NSDistributedNotificationCenter.DefaultCenter;
           NotificationHandler h = handler;
nc.AddObserverSelectorNameObject((Id)this, h, (NSString)null, (Id)null);
       }

       void handler(NSNotification n)
       {
           Console.WriteLine("name=" + n.Name);
       }
   }
}


What fails is the nc.AddObserverSelectorNameObject() call, since the delegate h cannot be converted to an IntPtr. I have no idea what that IntPtr actially represents. I am sorry if this is a simple question, but I am very new to MacOSX programming and Cocoa, and do not know ObjC at all.

Many thanks,
Miguel

--


*Miguel De Buf*
Chief Technology Officer
Aventiv NV, creators of NomaDesk® <http://www.NomaDesk.com/>
Tel. +32 9 233 68 86 (/Belgium/)
Fax +32 9 240 10 39 (/Belgium/)
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

Confidentiality Notice:
/This message, together with any attachments, is intended only for the use of the individual or entity to which it is addressed. It may contain information that is confidential and prohibited from disclosure. If you are not the intended recipient, you are hereby notified that any dissemination or copying of this message or any attachment is strictly prohibited. If you have received this item in error, please notify the original sender and destroy this item, along with any attachments./


Reply via email to