Quote:
Originally Posted by noobCoder
Hi all,
I have a quick problem I am hoping somebody could help me with, I am trying to refresh a view background at a User determined speed through the use of an NSTimer.
I have a TextView that you can enter a value, I then convert this to an integer and pass it to the NSTimer which in turn calls a method which updates the background as follows.
timerBackground = [NSTimer scheduledTimerWithTimeInterval: TEXTVIEWVALUE
target:self
selector:@selector(methodCall)
userInfo:nil
repeats:YES];
but the value I am trying to set seems sporadic and not updating at a speed which it should be.
Anybody see what I am doing wrong?
Thanks
|
The code you posted looks fine, ignoring some style issues.
Why don't you add a log statement to display the value of TEXTVIEWVALUE before you set up the timer:
Code:
NSLog(@"Timer value = %f", (float) TEXTVIEWVALUE);
timerBackground = [NSTimer scheduledTimerWithTimeInterval: TEXTVIEWVALUE
target:self
selector:@selector(methodCall)
userInfo:nil
repeats:YES];
Time intervals are floating point values expressed in seconds.
By the way, Cocoa variable names begin with a lower case letter by convention. Then the first letter of each word in a variable name is usually capitalized.
Labels that begin with upper case are supposed to be class names. Most people use all upper case for constants.
So your variable name should be "textViewValue".