保持命令行工具处于活动状态 [英] Keep command line tool alive
本文介绍了保持命令行工具处于活动状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何让命令行工具永远运行.
How would a keep a command-line tool running for ever.
这是我的代码:
#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;
}
推荐答案
您需要使用 CFRunLoop 或 NSRunLoop 进入运行循环.
You need to enter into a runloop using either CFRunLoop or NSRunLoop.
试试:
[[NSRunLoop currentRunLoop] run];
这篇关于保持命令行工具处于活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文