Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7975579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:40:56+00:00 2026-06-04T08:40:56+00:00

I am new to iOS programming. I am working on words matching game. In

  • 0

I am new to iOS programming. I am working on words matching game. In this game I need to implement time counter which shows minutes and seconds. I want when my game is started my timer to start with 3 minutes. Now I want to decrease this timer in reverse direction with seconds. my code just work for seconds..here is my code:

  secondsLeft--;

  int seconds = (secondsLeft %3600) % 60;

  Timerlbl.text = [NSString stringWithFormat:@"%02d",seconds];


  if (seconds==0)

{


 UIAlertView *pAlert = [[UIAlertView alloc]initWithTitle:@"Sorry!!"   
 message:@"TimeOver"        delegate:self    cancelButtonTitle:@"OK"   
 otherButtonTitles:@"Cancel",nil];

 [pAlert show];

[pAlert release];

 }

 }

In Viewdidload i call it through timer..

          countDown=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self 
                 selector:@selector(TimeOver) userInfo:nil repeats:YES];

pleas any one guide me how can i do it in both minutes and seconds.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:40:58+00:00Added an answer on June 4, 2026 at 8:40 am

    You can do it like this(ARC Enabled):-

    @interface ViewController()
    {
    UILabel *progress;
        NSTimer *timer;
        int currMinute;
        int currSeconds;
    }
    @end
    
    
    @implementation ViewController
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        progress=[[UILabel alloc] initWithFrame:CGRectMake(80, 15, 100, 50)];
        progress.textColor=[UIColor redColor];
        [progress setText:@"Time : 3:00"];
        progress.backgroundColor=[UIColor clearColor];
        [self.view addSubview:progress];
        currMinute=3;
        currSeconds=00;
    
        // Do any additional setup after loading the view, typically from a nib.
    }
    -(void)start
    {
        timer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired) userInfo:nil repeats:YES];
    
    }
    -(void)timerFired
    {
    if((currMinute>0 || currSeconds>=0) && currMinute>=0)
    {
        if(currSeconds==0)
        {
            currMinute-=1;
            currSeconds=59;
        }
        else if(currSeconds>0)
        {
            currSeconds-=1;
        }
        if(currMinute>-1)
        [progress setText:[NSString stringWithFormat:@"%@%d%@%02d",@"Time : ",currMinute,@":",currSeconds]];
    }
        else
        {
            [timer invalidate];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to iOS programming and I am working on a easy project that
I am new at ios programming and I need some help, can't figure out
I'm new to iOS programming and am not sure what is wrong with this
i am new to iOS programming. i really need your help. i have a
I have a question. I am new to this ios programming. I am doing
i am new to iOS development i am working on an app which is
I'm new to iOS programming and I'm reading this tutorial to get along http://www.raywenderlich.com/1797/how-to-create-a-simple-iphone-app-tutorial-part-1
i'm just new to iOS Programming, so appreciate for any help. I'm trying to
I am new to iOS programming. I see that there are functions defined in
I'm new to Xcode and programming for iOS, so I might not get what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.