Skip navigation.
 
mlLog File Watcher
FROM : unc
DATE : Mon Nov 05 22:15:22 2007

Hi there

I tried to make something like a log file watcher (like tail):

---
- (void)awakeFromNib {
   logFile = [[NSFileHandle fileHandleForReadingAtPath:LOGFILE] init];
   if (!logFile)
        return;
   [logFile seekToEndOfFile];
   [[NSNotificationCenter defaultCenter] addObserver:self
                                            selector:@selector(fileDataAvailable:)
                                                name:NSFileHandleReadCompletionNotification
                                             object:logFile];
   [logFile readInBackgroundAndNotify];
}

- (void)fileDataAvailable:(NSNotification*)note {
   NSLog(@"new entry %@", [[NSString alloc] initWithData:
                           [[note userInfo] objectForKey:NSFileHandleNotificationDataItem]
                                                encoding:NSUTF8StringEncoding]);
   [logFile readInBackgroundAndNotify];
}
---

The problem is, I now get e "new entry" all the time... The [note 
userInfo] is empty.

---
2007-11-05 22:11:26.502 MyApp[4381:10b] new entry
2007-11-05 22:11:26.504 MyApp[4381:10b] new entry
2007-11-05 22:11:26.504 MyApp[4381:10b] new entry
---

Any help is appreciated.

Nils

Related mailsAuthorDate
No related mails found.