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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:42:17+00:00 2026-06-03T19:42:17+00:00

I have a UILabel that I would like to update. It has been added

  • 0

I have a UILabel that I would like to update. It has been added to the class by ctrl-cicking and adding through the XIB file. Im trying to update the label text after waiting for a short delay. As of now, there is nothing else going on except for the code below. Howver when I run this, the simulator blanks out for a moment and takes me straight to the last updated text. It doesnt show me the 100 just the 200.

How do I get the label to update like I want it to. Ultimately Im trying to have a timer of sorts decrement inside the label.

Label linked from the XIB to header file:

@property (strong, nonatomic) IBOutlet UILabel *timeRemainingLabel;

In Implmentation:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.timeRemainingLabel.text = @"100";
    sleep(1);
    self.timeRemainingLabel.text = @"200";    
}
  • It has been synthesized.

  • XCode 4.3.2, Mac OSX 10.7.3, iOS Simulator 5.1 (running iPad), iOS 5

  • 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-03T19:42:18+00:00Added an answer on June 3, 2026 at 7:42 pm

    The problem with your implementation is that the execution sequence does not leave the method while in the sleep. This is the problem, because the UI subsystem never gets a chance to update the label to the "100" value before it gets a command to set it to "200".

    To do this correctly, first you need to create a timer in your init method, like this:

    timer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target:self selector:@selector(updateLabel) userInfo:nil repeats: YES];
    

    Then you need to write the code for your updateLabel method:

    -(void) updateLabel {
        NSInteger next = [timeRemainingLabel.text integerValue]-1;
        timeRemainingLabel.text = [NSString stringWithFormat:@"%d", next];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UILabel that displays some chars. Like x, y or rpm. How
I have an application that has a UILabel displaying the current date and time,
I have an NSArray of strings that I would like to animate with a
I have an iPad app that I would like to work in the sideways
I have an iOS (4.0) app that I would like to change the alpha
I have a class that has a UIView as a property. Sometimes I pass
I have one UITextField that has a value and one UILabel that has text.
I have various UILabels that I would like to hide using a for-loop. @interface
I have subclassed UILabel to provide a copy menu and would like to add
I would like to add an auto scroll effect to a UILabel. I have

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.