Привет! Я использую NSFileHandle метод readInBackgroundAndNotify, чтобы получать уведомления об обновлении файла журнала.
У меня есть следующий код:
- (void)startReading
{
NSString *logPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Logs/MyTestApp.log"];
NSFileHandle *fh = [NSFileHandle fileHandleForReadingAtPath:logPath];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
selector:@selector(getData:)
name:NSFileHandleReadCompletionNotification
object:fh];
[fh readInBackgroundAndNotify];
}
- (void) getData: (NSNotification *)aNotification
{
NSLog(@"notification received");
}
Однако селектор никогда не вызывается и уведомление не принимается.