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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:57:00+00:00 2026-05-28T03:57:00+00:00

I’m writing an app that pulls a .txt file from the web, parses it

  • 0

I’m writing an app that pulls a .txt file from the web, parses it into a 2 dimensional array (essentially. It’s actually an NSMutableArray with an NSArray for each element) and then displays each NSArray inside of a UITableView (it loads each NSArray by using sublabels).

Anyways, once I scroll down to the 17th cell (index of 16) the app crashes…

The UITableView should have 483 cells (for testing purposes), but I can’t seem to scroll past the 16th cell without it crashing.

Edit to post code and error:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
[[tableView layer] setCornerRadius:3.0];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];

if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"identifier"]autorelease];
}

NSInteger artistIndex = 1;
NSInteger albumIndex = 3;
NSInteger dateIndex = 6;
NSInteger imageIndex = 5;

// ARTIST
CGRect frame = CGRectMake(59, 11, 244, 13);
UILabel *label = [[UILabel alloc]initWithFrame:frame];
label.font = [UIFont boldSystemFontOfSize:13];
label.textColor = [UIColor blackColor];
label.text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:artistIndex];
[cell addSubview:label];

// ALBUM (more like description...
frame = CGRectMake(60, 30, 244, 11);
label = [[UILabel alloc]initWithFrame:frame];
label.font = [UIFont boldSystemFontOfSize:11];
label.textColor = [UIColor darkGrayColor];
label.text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:albumIndex];
[cell addSubview:label];

// DATE
frame = CGRectMake(59, 49, 244, 10);
label = [[UILabel alloc]initWithFrame:frame];
label.font = [UIFont fontWithName:@"Helvetica" size:10.0];
label.textColor = [UIColor darkGrayColor];
label.textAlignment = UITextAlignmentRight;
label.text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:dateIndex];
[cell addSubview:label];

// IMAGE
NSString *urlString = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:imageIndex];
NSData *urlData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]];
UIImage *myImage = [[UIImage alloc]initWithData:urlData];
UIImageView *myImageView = [[UIImageView alloc] init];
myImageView.image = myImage;
myImageView.frame = CGRectMake(8,9,44,44);
[myImageView.layer setMasksToBounds:YES];
[myImageView.layer setCornerRadius:3.0];
[[cell contentView] addSubview:myImageView];

[urlData release];
[myImage release];
[myImageView release];
[label release];

return cell;

NOTE: I feel like this code is pretty awful… If you guys have any suggestions to clean it up, I’d love to hear it.

And here’s the error message:

* Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘* -[NSMutableArray objectAtIndex:]: index 6 beyond bounds [0 .. 3]’

  • 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-28T03:57:01+00:00Added an answer on May 28, 2026 at 3:57 am

    My guess is that you have this, and the others like it, backwards.

    label.text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:artistIndex];
    

    Try,

    label.text = [[musicList.list objectAtIndex:artistIndex] objectAtIndex:indexPath.row];
    

    In my experience, dealing with two-dimensional arrays in objective-c can be sometimes confusing. Especially when working with UITableViews.

    What makes me have a feeling I am right is this,

    NSInteger artistIndex = 1;
    NSInteger albumIndex = 3;
    NSInteger dateIndex = 6;
    NSInteger imageIndex = 5;
    

    1 + 3 + 6 + 5 = 15, and one more, at 16, is the precise index that you are crashing at.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I am writing an app with both english and french support. The app requests
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

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.