NSLog() 回调后不输出

发布于 2024-11-17 23:36:05 字数 631 浏览 4 评论 0原文

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

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

[[NSNotificationCenter defaultCenter] addObserver:self
                          selector:@selector(taskDidTerminate:)
                          name:NSTaskDidTerminateNotification
                          object:localTask];

有什么想法吗?

编辑:taskDidTerminate

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

I've got an NSLog invocation in a method that I know is getting called (I've set a breakpoint). But there's not output in that method, or at all after that method. When the app starts up, my NSLog statements are working fine. I'm wondering if this is some sort of threading issue.

NSLog stops in the taskDidTerminate method, which is a callback from an NSTask:

[[NSNotificationCenter defaultCenter] addObserver:self
                          selector:@selector(taskDidTerminate:)
                          name:NSTaskDidTerminateNotification
                          object:localTask];

Any ideas?

Edit: taskDidTerminate

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

新雨望断虹 2024-11-24 23:36:05

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

请参阅此处以获取参考。

As it turns out, it doesn't look like XCode likes it when you execute a task using /bin/bash -c (task) (commands). I've now changed it to directly execute the task, and now my NSLog() statements are working.

See here for a reference.

江湖正好 2024-11-24 23:36:05

添加 [task setStandardInput:[NSPipe pipeline]]; 可能会恢复您的日志,如 CocoaDev:NSTask

Adding [task setStandardInput:[NSPipe pipe]]; may bring your logs back as stated on CocoaDev: NSTask.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文