1
こんにちは私は、NSFileHandleのreadInBackgroundAndNotifyメソッドを使用して、ログファイルが更新されたときに通知を受け取ります。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");
}
を。
返信ありがとうございます:) startReadingが実際に呼び出されています。私NSはfileHandleをログに記録し、これが返すものです: –
indragie
私の問題を解決しました。シートウィンドウが実行ループをブロックしていました。 – indragie