In my iPhone application, I have a secondary thread that I made to complete tasks in the background, and every few milliseconds, the view needs to be updated (not from the main thread). I tried the following code in a subclass of UIView:
[self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];
This works great on a simulator, however, on my device, it is very laggy. The only thing I can think of is that the main thread is linked to the usual UIKit routines, i.e. my setNeedsDisplay is called for a long time when it should (after about half a second). I think this is because in another user-based code, I immediately call setNeedsDisplay and it works fine without any lag. The secondary stream has fewer side calculations than the user interface stream. This leads to some very bad visual effects in my application.
So, to summarize, how can I fix this problem?
UPDATE:
Is there any other way to show me that I need to update myself x times per second? what could be the best performance for me, if possible. I tried CADisplayLink without success ...
source share