我有一个调用 NSTask 的应用程序,(我已经编写了 NSTask 和 App 代码)并且 NSTask 在我想要将一行写到控制台的地方调用 NSLog。
问题是我看到来自 NSTask 的控制台消息,然后我看到调用进程输出相同的消息,带有双标头......
5/16/11 5:50:01 PM theNSTask[7934] BLAH BLAH BLAH
[0x0-0x256256].com.someid[7505] 2011-05-16 17:50:01.708 theNSTask[7934:903] BLAH BLAH BLAH
仅仅为了读取所需的输出(BLAH BLAH BLAH)就超级混乱。有没有解决这个问题的神奇设置?
谢谢,
——汤姆
NSTask* task = [[NSTask alloc] init];
NSString* path = [[NSBundle mainBundle] pathForAuxiliaryExecutable:@"theNSTask"];
[task setLaunchPath:path];
NSMutableArray* arguments = [NSMutableArray array];
// get the dict as base64 string (start with binary plist):
NSString* base64Dict = [[self class] base64FromDictionary:message];
[arguments addObject:base64Dict];
[task setArguments:arguments];
[task launch];
[self.runningTasks addObject:task];
[task release];