如何讓命令行工具永遠運行。讓命令行工具繼續運行
這是我的代碼:
#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