Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSLog() not outputting after callback

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];
}
like image 958
marchaos Avatar asked Oct 11 '22 14:10

marchaos


2 Answers

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.

like image 150
marchaos Avatar answered Oct 14 '22 01:10

marchaos


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

like image 44
0xced Avatar answered Oct 13 '22 23:10

0xced