As I understand it, the view of a NSViewController class must be loaded before anything can be changed in the view through setters and getters. The problem is, the view in the controller is supposed to display a countdown, so the view controller class has an NSTimer that will change a stringValue every second. But from what I can see, I have to use something like:
[instanceOfViewControllerClass view]
in another class so that the view will load and then setStringValue
would work.
I asked a similar question before but the answer was what I said above, at the time I didn't know I would have to continuously change the view.
Basically what I'm looking for is something that works like this:
//ViewControllerClass.m
-(void)startCountdown{
//here I make "invocation" using NSInvocation
[invocation setTarget:self];
[invocation setSelector:@selector(updateCountdown)];
timerLabelUpdater = [NSTimer timerWithTimeInterval:1 invocation:invocation repeats:YES];
}
-(void)updateCountdown {
//x would be calculated here by deducting 1 from an original amount of time
[timeLeftLabel setStringValue:@"x"];
}
Everything is working fine, if I put an NSLog in the updateCountdown it logs perfectly, which means it is running, I just can't get the label to change.
Using the answer above I've tried using [self view]
and [self loadView]
in several places in the code above, but neither of them make a difference.
I hope I've been clear on what I'm looking for this time, any help would be appreciated.