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

  • Home
  • SEARCH
  • 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 6026999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:31:36+00:00 2026-05-23T04:31:36+00:00

I am developing an application for the iPhone. The question I have is how

  • 0

I am developing an application for the iPhone. The question I have is how to display a new label with a different text every .5 seconds. For example, it would display Blue, Red, Green, Orange and Purple; one right after one another. Right now I am doing this:

    results = aDictionary;
    NSArray *myKeys = [results allKeys];
    NSArray *sortedKeys = [myKey sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
    int keyCount = [sortedKeys count];
    while (flag == NO) {


        NSTimeInterval timeMS = [startDate timeIntervalSinceNow] * -10000.0;            

        if (timeMS >= i) {
            ii++;
            i += 1000;
            NSLog(@"endDate = %f", timeMS);
            int randomNumber = rand() % keyCount  + 1;
            lblResult.text = [results valueForKey:[sortedKeys objectAtIndex:(randomNumber - 1)]];
            result = [results valueForKey:[sortedKeys objectAtIndex:(randomNumber - 1)]];
            lblResult.text = result;

       }
        if (ii > 25) {
            flag = YES;
        }
    }
    lblResult.text = [results valueForKey:[sortedKeys objectAtIndex:(sortedKeys.count - 1)]];

this function is called at the viewDidAppear Function and currently isn’t displaying the new labels. It only displays the one at the end. Am I doing anything wrong? What would be the best method to approach this?

  • 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-05-23T04:31:37+00:00Added an answer on May 23, 2026 at 4:31 am

    The problem is that you’re not giving the run loop a chance to run (and therefore, drawing to happen). You’ll want to use an NSTimer that fires periodically and sets the next text (you could remember in an instance variable where you currently are).

    Or use something like this (assuming that items is an NSArray holding your strings):

    - (void)updateText:(NSNumber *)num
    {
        NSUInteger index = [num unsignedInteger];
        [label setText:[items objectAtIndex:index]];
        index++;
    
        // to loop, add
        // if (index == [items count]) { index = 0; }
    
        if (index < [items count]) {
            [self performSelector:@selector(updateText:) withObject:[NSNumber numberWithUnsignedInteger:index] afterDelay:0.5];
        }
    }
    

    At the beginning (e.g. in viewDidAppear:), you could then call

    [self updateText:[NSNumber numberWithUnsignedInteger:0]];
    

    to trigger the initial update.

    You’d of course need to ensure that the performs are not continuing when your view disappears, you could do this by canceling the performSelector, or if you’re using a timer, by simply invalidating it, or using a boolean, or …

    And if you want to get really fancy, use GCD 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am developing a iphone application in a view-based project,(not navigation) however i would
I'm developing an iPhone application that have a TabBarController with two tabs. Each tab
I am developing an iPhone application in which I have a page in which
I'm developing an iPhone application which uses a TableView to display XML data. The
I'm developing an iPhone application. I have the following property: @property (nonatomic, retain) Point2D*
I am developing Iphone application. I have used SecKeyGeneratePair method of Security/Security.h framework. I
I'm developing an iPhone iOS4 application and one of the things that it have
My problem is : 1. I am developing an iPhone application i have proceded
I am developing an iPhone application . I have tested it on iPhone simulator
I have developing an iPhone application using xcode 4 which is compatible with iOS

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.