runloop

Difference between CFRunLoopRemoveSource and CFRunLoopSourceInvalidate

Hi, I was debugging a crash in my HID driver code on the Mac and found that the crash happened in the CFRunLoop. In the driver code I open the USB handles for the devices which match the VID and the PID which match my HID device and then set up an Interrupt call back for it using setInterruptReportHandlerCallback function and then add i...

What exactly is considered to be called the "Run Loop" here?

Before keeping on reading in the docs, my brain got stuck at this point: - (void)threadMainRoutine { BOOL moreWorkToDo = YES; BOOL exitNow = NO; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; // is this THE run loop? // some stuff... while (moreWorkToDo && !exitNow) { // or is THIS the run loop? // some stu...

How to create a Run Loop which is kicked only by performSelector... method calls?

Hey guys! I'm messing around with threads a little bit. Now consider this: I have a main thread. I start a new thread. In it's entry-point method, I want to make a run loop. Now the documentation tells meh that I have to have a input source. Otherwise my run loop exits immediately. bad. okay. but I have no other input source than my perf...

Enqueue a selector to the run loop - is [NSObject performSelector:withObject:afterDelay:] the way to go?

Hi guys, I'd like to have a method be executed after the current method has passed and the UI has been updated. For that purpose, I'm using [object performSelector:@selector(someSelector) withObject:someObject afterDelay:0.0] right now. According to Apple's documentation, this creates a NSTimer which will then trigger and append the sel...

When is a Cocoa callback given controll?

Hi, I've been searching around the web for an answer to this one, but was unable to find an answer, on the other side I think it's something quite common thus there is a possibility I'm missing some keywords here. Anyhow, the problem is as follows: When is control given to a callback function in ObjC (iPhone)? Does it happen after con...

iPhone: how to prioritize items in a CFRunLoop (OpenGL related)

I have an OpenGL application which is rendering intensive and also fetches stuff over HTTP. Following Apple's samples for OpenGL, I originally used NSTimer for my main painting loop, before finding out (like everyone else) that it really isn't a good idea (because you sometimes have huge delays on touch events being processed when slow ...

iPhone - array lost between appDidBecomeActive: and run loop starting?

EDIT: I stuck in a single call to manually retain the array right after initializing it, and that fixed it. Dur. Thanks. I keep an NSMutableArray in a UIScrollView subclass, and I add to it instances of a UIImageView subclass as each is added as a subview. It needs to be a mutable array, as I plan to rearrange their order in the array e...

Running NSTimer on a thread

I am trying to run a NSTimer on a thread using iPhone SDK 3.0. I think I am doing everything correctly (new runloop etc.). If I call [timer invalidate] on viewDidDissappear though I get this error: bool _WebTryThreadLock(bool), 0x3986d60: Tried to obtain the web lock from a thread other than the main thread or the web thread. This ma...

How do I make the pasteboard be handled in a secondary runloop ?

Hi, I need to make a pasteboard owner run on a thread which is not the main thread. This is because the main thread needs to do other stuff, and rendering the pasteboard data might be time-consuming. I thought of removing the pasteboard owner from the main CFRunLoop, and adding it to the CFRunLoop of another thread, but exactly how sh...

[NSOperationQueue vs Runloop] cancelPreviousPerformRequest vs cancelAllOperations

i use now both but i'm not sure which is better. what is exactly the difference? fuzzy question i know. preparing for wwdc ...

How to use asyncsocket setRunLoopModes with separate thread?

I am new to cocoa and in my cocoa application, I'm trying to create the websocket in a new thread but it is not working. I'm doing the following when initializing mySocket class, NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(runEventLoop) object:nil]; [thread start]; .... - (void) runEve...