Inserting a task into the run loop
Inserting a task into the run loop
- Subject: Inserting a task into the run loop
- From: Graham Cox <email@hidden>
- Date: Sun, 22 Mar 2015 15:27:07 +1100
I have a requirement that runs my code exactly once per run loop, and I'm wondering what the modern preferred way to do this is.
I've developed the code using a timer with a very fast rate which I know can't really be met, so effectively it's calling back once per loop, but I figure there has to be a supported way to do that.
Is using -[NSRunLoop addPort:forMode:] the way to do this, or would using an NSOperation on the main queue be better? Since my code loops continuously, creating a separate new task each turn of the loop seem inefficient - better if there's something I can create once and it is called once per loop until I tell it to stop.
I've never had call to do this before, so I'm not sure what I should be doing here.
--Graham
_______________________________________________
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