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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:25:42+00:00 2026-05-13T00:25:42+00:00

I have an int which defines the objectAtIndex, which gives it to the string,

  • 0

I have an int which defines the objectAtIndex, which gives it to the string, which then displays it in the UILabel, HOWEVER, when I modify the array (add a word to it in this case) when I have the UILabel go through the array it only displays the odd ones. I have done an NSLog and found out that it DOES PASS EVERY SINGLE THING to the string, but the Label isn’t displaying every single one, it only does it the first time, then I modify the array, and it only does odd

edit: the code:

- (void) stuff {
    NSArray *indivwords = [sentence componentsSeparatedByString:@" "];
    count = [indivwords count]; //count=int
    if (i < count) {
        NSString *chunk = [indivwords objectAtIndex:i];
        [word setText:chunk];

        NSLog(chunk);
        i++;
    } else {
        word.textColor = [UIColor greenColor];
        [word setText:@"DONE"];
    }
}

All of this is being controlled by an NSTimer, which sets it off based on a slider value. Also i is set to 0 in the IBAction

The IBAction code:

word.textColor = [UIColor whiteColor];
[timer invalidate];
i = 0;

speedd = (1/speed.value)*60;



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

EDIT:

I fixed it! What I did was call this after i reached the count

 -(void)stoptimer
{
[timer invalidate];
timer = [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(empty) userInfo:nil repeats:YES];  
}

empty is just a void with nothing in it, well, all I did was add a comment,

//don't look over here, nothing to see here, oh look at that

Somebody can close this if they want

  • 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-13T00:25:42+00:00Added an answer on May 13, 2026 at 12:25 am

    You said the time interval of your NSTimer is controlled by a slider. Perhaps you are starting a new timer instance every time you change the slider value, so after a change you would have two timers running. The first one updates the label and increments i. The second one comes right after the first and finds i‘s value incremented, so it displays the next chunk instead of the current one.

    Count the instances of your timer – NSLog the timer in the timer callback and compare the results – it may be that you’re firing more than one.

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

Sidebar

Related Questions

I have an int array which has no elements and I'm trying to check
I have two tables which looks something like this Table Queue int ID; string
I have a table in db2 which has the following fields int xyz; string
Suppose you have a Java class which defines a copyFile(String, String) method: public class
Hi I want to have two tables each have an INT id column which
I have List I want to sort Desc by Priority, which is int and
I have a simple C function which I declare as: int strLen(const char* str_)
I have 2 tables which in simplified form look like this: Products( id: int,
We have the following object int [,] oGridCells; which is only used with a
I have a product table which simplifies to this: create table product(id int primary

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.