I'm scheduling events on the main run loop using the following code:
[stream setDelegate:self];
[stream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
[stream open];
I assume that this means that NSStreamDelegate
events are being scheduled on the main run loop and therefore can potentially impact UI responsiveness if frequent enough. This certainly seems to be the case in my program - even if the event handlers detach into a background thread without doing much work themselves.
How would I go about scheduling on a run loop other than mainRunLoop
? Do I need to create a thread? Can I just create an NSRunLoop directly? What setup needs to be performed?