NSLog()在回调后不输出

mar*_*aos 5 cocoa objective-c nslog

我在一个我知道被调用的方法中有一个NSLog调用(我设置了一个断点).但是在那种方法中没有输出,或者在该方法之后根本没有输出.当应用程序启动时,我的NSLog语句工作正常.我想知道这是否是某种线程问题.

NSLog在taskDidTerminate方法中停止,该方法是来自NSTask的回调:

[[NSNotificationCenter defaultCenter] addObserver:self
                          selector:@selector(taskDidTerminate:)
                          name:NSTaskDidTerminateNotification
                          object:localTask];
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

编辑:taskDidTerminate

- (void) taskDidTerminate: (NSNotification *) notification 
{
    NSLog(@"TaskDid Terminate");
    [task.delegate taskCompleted:task];
}
Run Code Online (Sandbox Code Playgroud)

mar*_*aos 2

事实证明,当您使用 /bin/bash -c (任务) (命令) 执行任务时,XCode 看起来并不喜欢它。我现在已将其更改为直接执行任务,现在我的 NSLog() 语句正在运行。

请参阅此处以供参考。