I have error handling code like this:
if (ERROR) {
NSLog(@"<some message>");
exit(-1);
}
The message logged with NSLog doesn’t always appear in the console, presumably because exit() terminates the process without flushing NSLog’s buffers. How can I flush NSLog’s buffers myself?
Try the following:
But you should not use
exitin production code because Apple Human Interface Guidelines say it clearly: