I need some help.
I want to use Cocoa to develop apps and I know enough about how to use project/interface builder to do so and i am very experiences in C and the Carbon toolbox. What I want is to perform a function repeatedly every n milliseconds, but how can I do this since control of the application is passed over to NSApplicationMain() ?

I need to check a port for incoming data constantly as well as responding to the GUI and I also wish to utilise threading but I cannot see where to place the code or even how to go about doing so with Cocoa (when I start a default project anyhow). Is there a Timer class anywhere and where is the documantation for it if so. In any case where would I put the code to initialise the timer - just before NSApplicationMain()?



Look in NSTimer for the kind of thing you want to do; a typical call is something like:
 NSTimer *timer = [[NSTimer	scheduledTimerWithTimeInterval:0.15
                                repeats:YES] retain];
This calls [self update:timer] every 0.15 seconds.

You can do this in a separate thread if you want but it's not really necessary. Plus, there are all sorts of problems with using separate threads (e.g., you can only do IO from the main application thread, I think).