Re: [Pyobjc-dev] how do I get a NSDistributedNotification?
Brought to you by:
ronaldoussoren
From: Ben A. <be...@ar...> - 2009-07-06 22:13:20
|
> Tried a simple interactive approach which did nothing. Is this > possible to do and if so what is the minimum necessary to do it? > > I tried: >>>> from Foundation import * > >>>> class O(NSObject): > ... def printNotif(self,notice): > ... print notice > >>>> nc = NSDistributedNotificationCenter.defaultCenter() >>>> nc.addObserver_selector_name_object_(o, o.printNotif, > "SomethingChanged", nil) > > and posted the notification from another python shell. Nothing > received. Runloop missing? Something else? If I recall correctly, you need a runloop, and you need to make sure that your observer doesn't go out of scope before you get the notification, because the DNC doesn't retain it. -- <http://artins.org/ben> "Calling computing 'computer science' is like calling surgery 'knife science'." -- Edsger Dijkstra |