10-23-2010, 07:58 AM
#1 (permalink )
Registered Member
Join Date: Sep 2010
Posts: 53
$10 - timer to count in .1 second increments help!!
I need the timer on my app to count in .1 second increments and it currently only counts in one second increments and despite my efforts I cant do it, obviously I'm pretty unexperienced. Please help, first person to solve my issue will get $10 AUS (worth more then 10 US at the moment!) through paypal.
I have the time displayed as a label.
in .m
Quote:
- (IBAction)start{
myTicker = [NSTimer scheduledTimerWithTimeInterval: 1 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
stopButton.hidden = NO;
startButton.hidden = YES;
resetButton.hidden = YES;
}
- (IBAction)stop{
[myTicker invalidate];
}
}
- (void)showActivity{
int currentTime =[time.text intValue];
int newTime = currentTime + 1;
time.text = [NSString stringWithFormat:@"%d", newTime];
}
It all works for counting in seconds. I'm not experienced so could you please tell me how to fix this issue in a bit of detail.
Cheers
Last edited by elfarez; 10-23-2010 at 08:02 AM .
10-23-2010, 08:11 AM
#2 (permalink )
Indie Developer
Join Date: Jul 2010
Posts: 1,346
- (IBAction)start{
myTicker = [NSTimer scheduledTimerWithTimeInterval:
0.1 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
stopButton.hidden = NO;
startButton.hidden = YES;
resetButton.hidden = YES;
}
Quote:
Originally Posted by
elfarez
I need the timer on my app to count in .1 second increments and it currently only counts in one second increments and despite my efforts I cant do it, obviously I'm pretty unexperienced. Please help, first person to solve my issue will get $10 AUS (worth more then 10 US at the moment!) through paypal.
I have the time displayed as a label.
in .m
It all works for counting in seconds. I'm not experienced so could you please tell me how to fix this issue in a bit of detail.
Cheers
10-23-2010, 08:26 AM
#3 (permalink )
Registered Member
Join Date: Sep 2010
Posts: 53
Sorry i should have been more clear. I want the timer to show the time increasing in .1 sec increments e.g. 0.1,0.2,0.3 ect.
Cheers
Please help.
Last edited by elfarez; 10-23-2010 at 09:58 AM .
10-23-2010, 12:11 PM
#4 (permalink )
Banned
Join Date: Jul 2009
Posts: 576
Quote:
Originally Posted by
elfarez
Sorry i should have been more clear. I want the timer to show the time increasing in .1 sec increments e.g. 0.1,0.2,0.3 ect.
Cheers
Please help.
For the timeInterval in the code that iSDK gave you, use a variable...
Initialize it with...
Code:
float timeInterval;
timeInterval =0.1;
then increment it with...
Code:
timeInterval = timeInterval + 0.1;
myTicker = [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
That should work.
If you are offering payment, give it to iSDK. He deserves it.
Thanks
Last edited by Not_Appy_At_All; 10-23-2010 at 12:19 PM .
10-23-2010, 10:07 PM
#5 (permalink )
Registered Member
Join Date: Sep 2010
Posts: 53
Quote:
Originally Posted by
Not_Appy_At_All
For the timeInterval in the code that iSDK
Code:
float timeInterval;
timeInterval =0.1;
then increment it with...
Code:
timeInterval = timeInterval + 0.1;
myTicker = [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
Sorry could you please tell me how to apply this code, I'm a beginner and have next to no experience. I'm just trying a few very basic projects to learn the basics of Xcode.
Cheers
10-23-2010, 10:37 PM
#6 (permalink )
Pro. Game Developer
iPhone Dev SDK Supporter
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
I don't see anything posted so far that will do what you want, so here's something that will get you relatively close:
Code:
- (IBAction)start
{
myTicker = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
stopButton.hidden = NO;
startButton.hidden = YES;
resetButton.hidden = YES;
}
- (IBAction)stop
{
[myTicker invalidate];
myTicker = nil;
}
- (void)showActivity
{
float currentTime = [time.text floatValue];
float newTime = currentTime + 0.1f;
time.text = [NSString stringWithFormat:@"%.1f", newTime];
}
Note that the technique used in this code does not provide the most accurate display possible, but it's simple and should probably do the trick for you.
10-23-2010, 10:42 PM
#7 (permalink )
Banned
Join Date: Jul 2009
Posts: 576
Quote:
Originally Posted by
Kalimba
I don't see anything posted so far that will do what you want, so here's something that will get you relatively close:
Code:
- (IBAction)start
{
myTicker = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
stopButton.hidden = NO;
startButton.hidden = YES;
resetButton.hidden = YES;
}
- (IBAction)stop
{
[myTicker invalidate];
myTicker = nil;
}
- (void)showActivity
{
float currentTime = [time.text floatValue];
float newTime = currentTime + 0.1f;
time.text = [NSString stringWithFormat:@"%.1f", newTime];
}
Note that the technique used in this code does not provide the most accurate display possible, but it's simple and should probably do the trick for you.
That's what he was asking?
Interesting as it seemed much too simple.
I interpreted his question to mean...have my repeating timer fire at 0.1, then 0.2, then 0.3 etc intervals... a math progression so to speak.
And all he wanted was a label display.
Coded of course.
Looks like Kalimba is owed the money.
10-23-2010, 10:49 PM
#8 (permalink )
Registered Member
Join Date: Sep 2010
Posts: 53
Dear Kalimba,
Thankyou so much!
PM me your paypal account thing so i can send you the money
10-23-2010, 10:53 PM
#9 (permalink )
Pro. Game Developer
iPhone Dev SDK Supporter
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
Quote:
Originally Posted by
elfarez
Dear Kalimba,
Thankyou so much!
PM me your paypal account thing so i can send you the money
There's a "Say thanks here" link in my signature, just below.
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 378
13 members and 365 guests
Abidullah , AppRocketeer , baja_yu , Brandt , BSH , Kryckter , Meoz , Punkjumper , sledzeppelin , SLIC , stanny , Tomsky , wassupdoc
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,646
Threads: 94,111
Posts: 402,867
Top Poster: BrianSlick (7,990)
Welcome to our newest member, locombiano89