如何让命令行工具永远运行。让命令行工具继续运行
这是我的代码:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
[[NSDistributedNotificationCenter defaultCenter] addObserverForName:nil object:nil queue:nil usingBlock:^(NSNotification *notification)
{
NSLog(@"%@", notification);
}];
//Keep alive...
}
return 0;
}
它应该是'NSRunLoop'大写L,但否则它完美地工作。 – Tyilo 2012-02-26 00:39:43
修正大写。 – EricS 2012-02-26 00:49:16
就是这样,谢谢! – Andy 2015-12-26 18:53:21