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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:18:54+00:00 2026-06-13T23:18:54+00:00

-(IBAction)someMethod:(UIStepper *)sender{ int x=sender.value; //This is an integer from 0-8; NSLog(@%f,sender.value); NSArray *rpmValues =

  • 0
-(IBAction)someMethod:(UIStepper *)sender{
    int x=sender.value; //This is an integer from 0-8;
    NSLog(@"%f",sender.value);
    NSArray *rpmValues = [[NSArray alloc]initWithObjects:@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i", nil];
    if (x<=[rpmValues count]) {

        myLabel.text = [rpmValues objectAtIndex:x];
    }
    NSLog(@"%i",[rpmValues count]);
}

Above is my code, what I want to do is to change UILabel display by changing UIStepper. This is very straight forward. But when I change press the stepper value, it crashes:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -   [__NSArrayM objectAtIndex:]: index 1 beyond bounds for empty array'
*** First throw call stack:

And the [rpmValue count] is 9. I really got confused. Can anyone help me?

  • 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-13T23:18:55+00:00Added an answer on June 13, 2026 at 11:18 pm

    That code seems fine (see my comment on the question); your problem could arise from the use of

    if (x<=[rpmValues count]) {
    

    This will include the count of the array, which exceeds the index range by one. Use

    if (x < [rpmValues count]) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

- (IBAction)EnterButtonPressed:(id)sender { Sqlite *sqlite = [[Sqlite alloc] init]; NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString
-(IBAction)flipView:(id)sender { MapController *nextVC = [[MapController alloc] initWithNibName:@MapController bundle:nil]; nextVC.title = @Map; nextVC.longi =
Some simple code: - (IBAction)Up_Down:(UIStepper *)sender { double value = [sender value]; [NumDayLabel setText:[NSString
-(IBAction)buttonPressed1:(id)sender { SignView *tempVC = [[SignView alloc] initWithNibName:@SignView bundle:Nil]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationTransition:
-(IBAction) btnReturn:(id) sender{ firstView * firstview =[[firstView alloc]initWithNibName:@firstView bundle:nil]; [self.view pushViewController:firstview animated:NO]; } with
-(IBAction)customizeYourGameButtonClicked:(id)sender { [self playHumanHitSound]; self.customizeYourGameViewController = [[CustomizeYourGameViewController alloc] initWithNibName:@CustomizeYourGameViewController bundle:nil]; [self.navigationController pushViewController:customizeYourGameViewController animated:YES]; [customizeYourGameViewController
- (IBAction)doUpload:(id)sender { NSMutableArray *selected_items = [[NSMutableArray alloc] init]; for (int i = 0;
-(IBAction)Done :(id) sender { NSMutableArray *addinfo = [[NSMutableArray alloc]init]; AddinfoCarteV *addinfoCarteV =[[AddinfoCarteV alloc]initWithNibName:@AddinfoCarteV bundle:nil];
I have this code: - (IBAction)open:(id)sender{ [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view
-(IBAction)gameplayButtonClicked{ GamePlayViewController *screen3 = [[GamePlayViewController alloc] initWithNibName:nil bundle:nil]; screen3.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentModalViewController:screen3 animated:YES];

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.