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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-16-2011, 01:43 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 24
gadsadasd is on a distinguished road
Default Very simple countdown

Hi, I want to create a simple countdown two
minutes. Every second that every time you change the number issued
a sound. A very simple thing: A UIButton and UILAbel.
Thanks thanks
gadsadasd is offline   Reply With Quote
Old 02-16-2011, 01:58 PM   #2 (permalink)
Registered Member
 
simplyDusty's Avatar
 
Join Date: Jan 2011
Posts: 158
simplyDusty is on a distinguished road
Default

Quote:
Originally Posted by gadsadasd View Post
Hi, I want to create a simple countdown two
minutes. Every second that every time you change the number issued
a sound. A very simple thing: A UIButton and UILAbel.
Thanks thanks
Use the button's pressed event to start an NSTimer that triggers a method every second for two minutes. In that method update your label and play your sound.

Code:
NSTimer *timer;
int seconds;

-(IBAction)buttonPressed:(id)sender
{
    timer = [NSTimer timerWithTimeInterval:1.0
    target:self
    selector:@selector(Update:)
    userInfo:nil
    repeats:YES];
}

-(void)Update
{
   // update your label
   // play your sound
   
   seconds++;
   
   if (seconds > 120)
   {
      [timer invalidate];
      timer = nil;
   }
}
Something like that would probably work. May be some errors...
simplyDusty is offline   Reply With Quote
Old 02-16-2011, 02:09 PM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 24
gadsadasd is on a distinguished road
Default

Quote:
Originally Posted by simplyDusty View Post
Use the button's pressed event to start an NSTimer that triggers a method every second for two minutes. In that method update your label and play your sound.

Code:
NSTimer *timer;
int seconds;

-(IBAction)buttonPressed:(id)sender
{
    timer = [NSTimer timerWithTimeInterval:1.0
    target:self
    selector:@selector(Update:)
    userInfo:nil
    repeats:YES];
}

-(void)Update
{
   // update your label
   // play your sound
   
   seconds++;
   
   if (seconds > 120)
   {
      [timer invalidate];
      timer = nil;
   }
}
Something like that would probably work. May be some errors...
unfortunately does not work or might not get it to work.
The operation that I want is simply the fact
and a countdown showing the time UILabel. And then
every second for a sound.
Thanks
gadsadasd is offline   Reply With Quote
Old 02-16-2011, 02:12 PM   #4 (permalink)
Registered Member
 
simplyDusty's Avatar
 
Join Date: Jan 2011
Posts: 158
simplyDusty is on a distinguished road
Default

You'll need to explain what you're asking better...
simplyDusty is offline   Reply With Quote
Old 02-16-2011, 02:44 PM   #5 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 24
gadsadasd is on a distinguished road
Default

Quote:
Originally Posted by simplyDusty View Post
You'll need to explain what you're asking better...
I do not know how to explain. Here is a picture:
gadsadasd is offline   Reply With Quote
Old 02-16-2011, 03:06 PM   #6 (permalink)
Registered Member
 
simplyDusty's Avatar
 
Join Date: Jan 2011
Posts: 158
simplyDusty is on a distinguished road
Default

That's what I thought. It would be done the way I showed in my first post. That should be enough to get you started, no one here is going to write all of the code for you.
simplyDusty 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: 374
10 members and 364 guests
cpsclicker, Error404, gmarro, jeroenkeij, Kirkout, Music Man, PavelMik, teebee74, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,666
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, cpsclicker
Powered by vBadvanced CMPS v3.1.0

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