Run NSRunLoop in a Cocoa command-line program

前端 未结 6 1686
遥遥无期
遥遥无期 2020-11-27 04:20

Is it possible to initialize a NSRunLoop without loading any NIB files (i.e., without calling NSApplicationMain())?

Thanks.

6条回答
  •  眼角桃花
    2020-11-27 04:58

    Follow the recommendations in the docs for [NSRunLoop run]:

    BOOL shouldKeepRunning = YES;        // global
    NSRunLoop *theRL = [NSRunLoop currentRunLoop];
    while (shouldKeepRunning && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate     distantFuture]]);
    

提交回复
热议问题