Hi Jens,

My understanding is that dispatch queues are tied to threads that are
managed by the system and are separate from run loops. It's therefore
non-sensical to ask for a runloop's queue.

Regardless though, I think a better solution for you is a category on
NSTimer. I use something like the following:

====================
@implementation NSTimer (BlockTimersYay)
+ (NSTimer *)scheduledTimerWithTimeInterval:
(NSTimeInterval)timeInterval repeats: (BOOL)repeats block: (void
(^)(void))block
{
    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:
timeInterval target: self selector: @selector(fireBlockTimer:)
userInfo: [[block copy] autorelease] repeats: repeats];
    [[NSRunLoop currentRunLoop] addTimer: timer forMode: NSRunLoopCommonModes];
    return timer;
}
+ (void)fireBlockTimer: (NSTimer *)blockTimer
{
    ((void (^)(void))[blockTimer userInfo])();
}
@end
====================

Note that this is slightly different than NSTimer in that the timer is
added to the common modes rather than the default mode.
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to