Skip to content

Instantly share code, notes, and snippets.

@bygri
Forked from syzdek/cli-nsrunloop.m
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bygri/2fa86d1c23c625d6153c to your computer and use it in GitHub Desktop.
Save bygri/2fa86d1c23c625d6153c to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSRunLoop *runLoop;
CLIMain *main; // replace with desired class with properties BOOL shouldExist and int exitCode
@autoreleasepool
{
runLoop = [NSRunLoop currentRunLoop];
main = [[CLIMain alloc] init]; // replace with init method and manually start, if required
while(
!main.shouldExit &&
[runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:2]]
);
}
return(main.exitCode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment