Re: Confused about CFRunLoop
Re: Confused about CFRunLoop
- Subject: Re: Confused about CFRunLoop
- From: Rob Keniger <email@hidden>
- Date: Tue, 18 Mar 2008 14:04:17 +1000
On 18/03/2008, at 1:26 PM, Brian Greenstone wrote:
I was using NSTimer originally, but I was having the exact same
problem since NSTimer is really just a CFRunLoopTimerRef according
to the docs. As far as I can tell, using NS calls to do this is
just a more complicated way than simply calling CF directly to do it
without all that Obj-C gibberish.
That being said, I'm really not trying to do anything funky. I'm
just trying to setup a Timer that will fire at 60 times/second to
call my game's main loop. Each time it fires, the passes thru the
game's main loop once. When the game is done, I exit the loop to
return to the game's menu or high-scores screen. The logic worked
great with those old Carbon calls, and everything is actually
working now with these CF run loop calls too, it's just that I'm not
getting mouse or keyboard events when I enter the loop. They're
being blocked. So, the big question is really: how do I enter a CF
run loop and keep getting keyboard and mouse events?
I don't use CFRunLoop, but I use this code to create a timer that does
not get stopped by keyboard/mouse events:
theTimer=[NSTimer timerWithTimeInterval:0.1 target:self
selector:@selector(doStuff:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:theTimer
forMode:NSRunLoopCommonModes];
Works great and it sounds like it will do what you want. The trick is
to set the run loop mode correctly, you can probably do something
equivalent with the CF calls if you like. I like my Obj-C gibberish so
I avoid CF if possible ;-)
--
Rob Keniger
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden