• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using notifications vs. listener lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using notifications vs. listener lists


  • Subject: Re: Using notifications vs. listener lists
  • From: Drew McCormack <email@hidden>
  • Date: Sun, 5 May 2002 10:49:20 +0200

On Sunday, May 5, 2002, at 01:11 AM, Dave Fayram wrote:

Hi,
I'm working on a cocoa app that relies heavily on libpcap and I realized I have a small
design dilemma I don't know the "cocoa" solution for. My little worker thread is going to be
reading packets of the bpf and it needs to let people know when it recieves appropriate
packets from various hosts. Sometimes, there could be long periods of time without any
packets, sometimes there could be hundreds a minute. I'd like to be able to register multiple,
arbitrary listeners to respond to these events.
My first reaction is to use the NSNotificationCenter and register listeners (passing the
germane info via the userinfo field) but I don't know if I should use an NSArray of listeners
and enumerate across that. What is the "Cocoa" way here? I'd like performance to be decent
as well and I really don't know how well NSNotifications work in terms of speed.

Could someone fill me in?
Posting notifications is definitely the way to go in Cocoa. There can sometimes be a problem with performance if there are a lot of notifications, but you can also coalesce them to improve performance. Check out the docs for NSNotificationQueue to see how to do this.

Drew McCormack


- Dave "Paradox" Fayram
My ElGamal and DSA keys can be found at:
http://zero.atomictrain.net:88/~paradox/pgpkey.html

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Dr. Drew McCormack
Trade Strategist (www.trade-strategist.com)
Trading simulation software for Mac OS X
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Using notifications vs. listener lists (From: Dave Fayram <email@hidden>)

  • Prev by Date: nsthread_kill()
  • Next by Date: An NSTask can only be run once ??
  • Previous by thread: Using notifications vs. listener lists
  • Next by thread: Philosophical Question
  • Index(es):
    • Date
    • Thread