Having a look at main.m and the run loop, comments added.