• 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
File updates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

File updates


  • Subject: File updates
  • From: email@hidden (mikevannorsdel)
  • Date: Sat, 17 Nov 2001 07:27:35 -0700

I'm using NSFileHandle's waitForDataInBackgroundAndNotify to watch a file for new data. I implement it like this:


//Start watch
NSFileHandle * file=[NSFileHandle fileHandleForReadingAtPath:filePath];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readFileData:) name:NSFileHandleDataAvailableNotification object:file];
[file waitForDataInBackgroundAndNotify];

//Method that processes data
- (void)readFileData:(NSNotification*)aNotification
{
...
...
//process new data
...
...
[[aNotification object] waitForDataInBackgroundAndNotify];
}

This works great, but it consumes a lot of CPU while waiting for data (~65%). Does waitForDataInBackgroundAndNotify not block until data is ready (like select()) and just constantly check the file? Did I implement this incorrectly? Is there a better way?


  • Prev by Date: Re: Standard OS X Compression format
  • Next by Date: Re: Standard OS X Compression format
  • Previous by thread: why is numbersOfRowInTableView called before awakeFromNib?
  • Next by thread: NSJPEGFileType / JPEG writer
  • Index(es):
    • Date
    • Thread