I have the following code which should make drawFrame be called every frame but it doesn't:
- (void)viewDidLoad
{
[super viewDidLoad];
displayLink = [viewReference.window.screen displayLinkWithTarget:(self) selector:@selector(drawFrame)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
- (void) drawFrame:(CADisplayLink*)sender
{
thel.text = @"test";
}
dispayLink is a pointer to CADisplayLink. thel is connected to a label in my view. This view is connected to viewReference. self is the ViewController. drawFrame is declared
- (void) drawFrame:(CADisplayLink*)sender;
thel.text can be set when I test it in viewDidLoad.
It seems drawFrame is never called. The application is based on Xcode 4.2s empty application template with a custom storyboard file (I added it afterwards rather than selecting use storyboard on creation). It is empty besides the view controller, the view and the label.
I'm new to this. When calling [[NSRunLoop currentRunLoop] run] iOS 5.0 Simulator doesn't display the app at all. The currentRunLoop should be the default main runLoop anyway.
Perhaps you need to set the CADisplaylink 'frameInterval' property:
displayLink.frameInterval = someRate (1-60);
Another interesting curiosity is that
weak private var _anim : CADisplayLink? // mysteriously does nothing
display links, for unknown reasons, simply don't run if the variable is weak.
private var _anim : CADisplayLink? // rock on