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 8228599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:30:39+00:00 2026-06-07T16:30:39+00:00

I’m working on my first big application and have inadvertently driven myself into a

  • 0

I’m working on my first big application and have inadvertently driven myself into a panic from a small flaw in design. I’ve made a timer that counts at the touch of a button, and upon a second touch, transitions into a secondary timer with a 60 second countdown.

The problem lies in the fact that once I repeat this process, the (kRest-Pause) call is remembered. I’m looking to create a default countdown of 60 without the continuation of the time. Should I kill it in memory and create a new instance for each subsequent button press? Or is there a logic game that looks at the aggregate time and corrects with each new occurance?

I don’t know how to approach this, I’m done attempting -if statements with returns as I have learned that’s not how that works. Any help would be appreciated

EDIT: Sorry for the lack of clarity. I’m pretty green on programming of any caliber. So far, the main timer counts down from 10-0 then up from 0-120. In that 2 minute period, if the button is pressed again, the 0-120 count is paused for 60 seconds or until the button is pressed for the third time. If this 60-0 countdown reaches 0 or is interrupted, the initial 0-120 countup resumes its count. My issue is that if I push the button a fourth time, the 60-0 countdown is resumed from the moment of interruption without retaining a default of 60. This is why I named the post “creating defaults in Objective C”. It’s the wrong use of the word and way to broad, but it’s what I could come up with.

kRest=60

-(void)increase{

    if (mode==1){
        count++;

        int d = 10-count;

        if (d==0){ timeLabel.text = @"Begin";
            [self startPlaybackForPlayer: self.startTimerSound];}

        else {timeLabel.text = [NSString stringWithFormat:@"%d", abs(d)];}

        if(d<0){
            //workign out
            active = TRUE;
            if (d <= -20) {
                [self stopTimer];                 
            }
        }
        else{
            //no user interface
            active = FALSE;



        }
    }
    else{
        pause++;
        countdownLabel.text = [NSString stringWithFormat:@"%d!", (kRest-pause)];
        NSLog(@"Paused at time %d", pause);


        UIColor *textColor = nil;
        if (pause % 2==0){
            textColor = [UIColor yellowColor];
        }
        else{
            textColor = [UIColor redColor];

        }
        timeLabel.textColor = textColor;

        if ((kRest-pause)==0){
            countdownLabel.text = [NSString stringWithFormat:@"%d!",pause];
            mode=1;
            pause=0;
            [button setTitle:@"Stop" forState:UIControlStateNormal];
            repCount++;
            myRepCount.text = [NSString stringWithFormat:@"Rep Count: %d", repCount];
            countdownLabel.text = @"";
        }
    }
}
  • 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-07T16:30:41+00:00Added an answer on June 7, 2026 at 4:30 pm

    if you are using a timer to access this counter then you should be able to update the counter that the timer uses. Just make sure you synchronize the object so you dont edit while you are reading.

    here is an example of what I mean.

    int counter = 0;
    
    int limit = 60;
    
    - (BOOL) incrementUntilReached{
    
        @synchronized(self){
            if (counter == limit) return YES;
            counter++;
            return NO;
        }
    }
    
    - (void) resetTimer{
        @synchronized(self){
            counter = 0;
        }
    }
    
    - (int) countsLeft {
        @synchronized(self){
            return limit - counter;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and

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.