• 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: NSFileHandleDataAvailableNotification problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileHandleDataAvailableNotification problems


  • Subject: Re: NSFileHandleDataAvailableNotification problems
  • From: Ken Thomases <email@hidden>
  • Date: Mon, 11 May 2009 18:14:00 -0500

On May 11, 2009, at 2:35 PM, Todd Heberlein wrote:

I have a problem reading periodic data from a file descriptor, and I am wondering if I am using the methods wrong. The basic code is below, but essentially I

(1) register my object to be called when an NSFileHandleDataAvailableNotification is sent to the notification center;

(2) create an NSFileHandle for the file descriptor and send it the waitForDataInBackgroundAndNotify method;

Try reversing the order of the above two steps and observe the specific NSFileHandle object. It's possible that there are other NSFileHandles out there (created by the framework?) and, as things stand, your method would be called whenever those post their notifications, too.


[...] Should I not call waitForDataInBackgroundAndNotify in the callback function?

Actually, you must if you want to be notified again.

Does reading from the file descriptor via read() instead of through the NSFileHandle cause problems?

It might. Have you tried using -availableData instead?

Alternatively, have you tried using -readInBackgroundAndNotify and the NSFileHandleReadCompletionNotification, getting the data from the notification's userInfo?


Any suggestions would be appreciated,

Make sure all of your memory management is correct. Retain the file handle object for as long as you need it to exist, etc.


Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSFileHandleDataAvailableNotification problems (From: Todd Heberlein <email@hidden>)

  • Prev by Date: Re: Listing running process
  • Next by Date: Re: Packages vs bundles vs folders etc
  • Previous by thread: NSFileHandleDataAvailableNotification problems
  • Next by thread: [iPhone] UITableView with state?
  • Index(es):
    • Date
    • Thread