Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Jobs and Commerce > Help Wanted

Reply
 
LinkBack Thread Tools Display Modes
Old 10-23-2010, 07:58 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 53
elfarez is on a distinguished road
Exclamation $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.
elfarez is offline   Reply With Quote
Old 10-23-2010, 08:11 AM   #2 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

- (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 View Post
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
iSDK is offline   Reply With Quote
Old 10-23-2010, 08:26 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 53
elfarez is on a distinguished road
Default

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.
elfarez is offline   Reply With Quote
Old 10-23-2010, 12:11 PM   #4 (permalink)
Banned
 
Join Date: Jul 2009
Posts: 576
Not_Appy_At_All is on a distinguished road
Default

Quote:
Originally Posted by elfarez View Post
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.
Not_Appy_At_All is offline   Reply With Quote
Old 10-23-2010, 10:07 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 53
elfarez is on a distinguished road
Default

Quote:
Originally Posted by Not_Appy_At_All View Post
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
elfarez is offline   Reply With Quote
Old 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
Kalimba is on a distinguished road
Default

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.
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 10-23-2010, 10:42 PM   #7 (permalink)
Banned
 
Join Date: Jul 2009
Posts: 576
Not_Appy_At_All is on a distinguished road
Default

Quote:
Originally Posted by Kalimba View Post
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.
Not_Appy_At_All is offline   Reply With Quote
Old 10-23-2010, 10:49 PM   #8 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 53
elfarez is on a distinguished road
Default

Dear Kalimba,

Thankyou so much!
PM me your paypal account thing so i can send you the money
elfarez is offline   Reply With Quote
Old 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
Kalimba is on a distinguished road
Default

Quote:
Originally Posted by elfarez View Post
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.
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:10 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0