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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:01:58+00:00 2026-06-17T14:01:58+00:00

I am a rookie in Xcode and I have been using the UITableViewController which

  • 0

I am a rookie in Xcode and I have been using the UITableViewController which shows this error.

This is the error message:
* Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘* -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]’
*
First throw call stack:
(0x1c91012 0x10cee7e 0x1c330b4 0x36d0 0xc58d5 0xc5b3d 0xacce83 0x1c50376 0x1c4fe06 0x1c37a82 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x1665c 0x2132 0x2065)
libc++abi.dylib: terminate called throwing an exception
(lldb)

This is my code:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


 if (indexPath.row == 0) {

    NSString *strURL = [NSString stringWithFormat:@"http://localhost:8888/GetDetail.php?choice=row0"];
    NSArray *arrayImagesNames = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:strURL]];


    arrayDataFromServer2 = [[NSMutableArray alloc]init];

    NSEnumerator *enumForNames = [arrayImagesNames objectEnumerator];

    id objName;

    while ( objName = [enumForNames nextObject]) {
        [arrayDataFromServer2 addObject:[NSDictionary dictionaryWithObjectsAndKeys:objName, @"name", nil]];
    }

    NSString *nn = [[arrayDataFromServer2 objectAtIndex:indexPath.row] objectForKey:@"name"];

    row1 = [nn intValue];
    NSLog(@"%d", row1);

    CompanyProfileViewController *profile = [self.storyboard instantiateViewControllerWithIdentifier:@"Profile"];
    [self.navigationController pushViewController:profile animated:YES];

    profile.profileid = row1;
    NSLog(@"%d", profile.profileid);
}

if (indexPath.row == 1) {

    NSString *strURL = [NSString stringWithFormat:@"http://localhost:8888/GetDetail.php?choice=row1"];
    NSArray *arrayImagesNames = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:strURL]];


    arrayDataFromServer2 = [[NSMutableArray alloc]init];

    NSEnumerator *enumForNames = [arrayImagesNames objectEnumerator];

    id objName;

    while (objName = [enumForNames nextObject]) {
        [arrayDataFromServer2 addObject:[NSDictionary dictionaryWithObjectsAndKeys:objName, @"name", nil]];
    }

    NSString *nn = [[arrayDataFromServer2 objectAtIndex:indexPath.row] objectForKey:@"name"];

    row1 = [nn intValue];
    NSLog(@"%d", row1);

    CompanyProfileViewController *profile = [self.storyboard instantiateViewControllerWithIdentifier:@"Profile"];
    [self.navigationController pushViewController:profile animated:YES];

    profile.profileid = row1;
    NSLog(@"%d", profile.profileid);
}

if (indexPath.row == 2) {

    NSString *strURL = [NSString stringWithFormat:@"http://localhost:8888/GetDetail.php?choice=row2"];
    NSArray *arrayImagesNames = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:strURL]];


    arrayDataFromServer2 = [[NSMutableArray alloc]init];

    NSEnumerator *enumForNames = [arrayImagesNames objectEnumerator];

    id objName;

    while ( objName = [enumForNames nextObject]) {
        [arrayDataFromServer2 addObject:[NSDictionary dictionaryWithObjectsAndKeys:objName, @"name", nil]];
    }

    NSString *nn = [[arrayDataFromServer2 objectAtIndex:indexPath.row] objectForKey:@"name"];

    row1 = [nn intValue];
    NSLog(@"%d", row1);

    CompanyProfileViewController *profile = [self.storyboard instantiateViewControllerWithIdentifier:@"Profile"];
    [self.navigationController pushViewController:profile animated:YES];

    profile.profileid = row1;
    NSLog(@"%d", profile.profileid);
}

if (indexPath.row == 3) {

    NSString *strURL = [NSString stringWithFormat:@"http://localhost:8888/GetDetail.php?choice=row3"];
    NSArray *arrayImagesNames = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:strURL]];


    arrayDataFromServer2 = [[NSMutableArray alloc]init];

    NSEnumerator *enumForNames = [arrayImagesNames objectEnumerator];

    id objName;

    while ( objName = [enumForNames nextObject]) {
        [arrayDataFromServer2 addObject:[NSDictionary dictionaryWithObjectsAndKeys:objName, @"name", nil]];
    }

    NSString *nn = [[arrayDataFromServer2 objectAtIndex:indexPath.row] objectForKey:@"name"];

    row1 = [nn intValue];
    NSLog(@"%d", row1);

    CompanyProfileViewController *profile = [self.storyboard instantiateViewControllerWithIdentifier:@"Profile"];
    [self.navigationController pushViewController:profile animated:YES];

    profile.profileid = row1;
    NSLog(@"%d", profile.profileid);
 }
}

When I click on the second cell (index.row == 1) this error would occur.
I have used breakpoint and the error was on the line:
“NSString *nn = [[arrayDataFromServer2 objectAtIndex:indexPath.row] objectForKey:@”name”];”

Please Help!

  • 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-17T14:02:04+00:00Added an answer on June 17, 2026 at 2:02 pm

    You have an array and you have either 0 or 1 elements in it. Now you are trying to extract 2nd element from it, [0] is first, and [1] is second.

    EDIT:

    As you are not sure when the array will contain 1 or more objects. Therefore you can use as:

    NSString *nn=nil;
    if([arrayDataFromServer2 count]>1){    
        nn = [[arrayDataFromServer2 objectAtIndex:indexPath.row] objectForKey:@"name"];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a rookie question, sorry. I developed a jsf-2 app (on Tomcat) which
This may be a rookie question but if I have created a suite of
Okay this is probably a rookie question, but I have never done GUI programming
A rookie here. I have this specific issue in implementing Model View Presenter Pattern
Im a RoR rookie and am using rails 3.2.3. I've been using devise and
This is probably a rookie question but; Let's say I have an ActionResult that
A rookie Racket question. I'm using Krishnamurthi's PLAI textbook for this one, and the
Rookie question: I have been experiencing a minor bug in my mvc2 application. I
I am a true rookie in JS, I have this code, in the body
This is likely a rookie error, but im in the early stages of learning

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.