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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:12:00+00:00 2026-05-25T13:12:00+00:00

I have a table view that i want to populate with information from xml.

  • 0

I have a table view that i want to populate with information from xml. In viewdidload I tell the parser to start parsing. I store the information in an NSMUtableArray.

However when I get to this function it gives me a SIGABRT

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...

    NSString *celltext = [profileItems objectAtIndex:indexPath.row]; //SGABRT here

    NSString *celltitle = [profileFieldNames objectAtIndex:indexPath.row];

    cell.detailTextLabel.text = celltext;

    cell.textLabel.text = celltitle;

    return cell;
}

I get a SIGABRT error saying “index 0 beyond bounds for empty array'” at the line:

NSString *celltext = [profileItems objectAtIndex:indexPath.row]; //SGABRT here

It seems that it is trying to put the data in the table before the parsing is complete. How do I avoid this?

Thanks

EDIT: Here is the code that does the parsing:

    - (void)parser:(NSXMLParser *)parser
   didStartElement:(NSString *)elementName
      namespaceURI:(NSString *)namespaceURI
     qualifiedName:(NSString *)qualifiedName
        attributes:(NSDictionary *)attributeDict
{
    currentElement = [[elementName copy] autorelease];
    if ([elementName isEqualToString:@"fullname"]) 
    {
        tfullname = [[NSMutableString alloc] init];
    }

    if ([elementName isEqualToString:@"DOB"])
    {
        tDOB = [[NSMutableString alloc] init]; 
    }

    if ([elementName isEqualToString:@"accommodation"])
    {
        taccommodation = [[NSMutableString alloc] init]; 
    }

    if ([elementName isEqualToString:@"nationality"])
    {
        tnationality = [[NSMutableString alloc] init]; 
    }

    if ([elementName isEqualToString:@"subject"])
    {
        tstudying= [[NSMutableString alloc] init]; 
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if ([currentElement isEqualToString:@"fullname"])
    {
        [tfullname appendString:string];
    }

    if ([currentElement isEqualToString:@"DOB"])
    {
        [tDOB appendString:string];
    }

    if ([currentElement isEqualToString:@"accommodation"])
    {
        [taccommodation appendString:string];
    }

    if ([currentElement isEqualToString:@"nationality"])
    {
        [tnationality appendString:string];
    }

    if ([currentElement isEqualToString:@"subject"])
    {
        [tstudying appendString:string];
    }
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    if ([elementName isEqualToString:@"fullname"]) 
    {     
        namelabelstring = tfullname;
        NSLog(@"second attemp your name is %@", namelabelstring);
    }

    if ([elementName isEqualToString:@"DOB"]) 
    {
        [profileItems addObject:tDOB];
    }

    if ([elementName isEqualToString:@"accommodation"])
    {
        [profileItems addObject:taccommodation];
    }

    if ([elementName isEqualToString:@"nationality"])
    {
        [profileItems addObject:tnationality];    }

    if ([elementName isEqualToString:@"subject"])
    {
        [profileItems addObject:tstudying];
    }
}

//////Here is the code where the arrays are created////////////

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;

    profileFieldNames = [[NSMutableArray alloc] init ];
    profileItems = [[NSMutableArray alloc] init];

    [profileFieldNames addObject:@"Date of Birth:"];
    [profileFieldNames addObject:@"Nationality:"];
    [profileFieldNames addObject:@"Accommodation:"];
    [profileFieldNames addObject:@"Studying:"];

    //[[self tableView] reloadData];

    [self loadmemberprofiledata];

    [[NSBundle mainBundle] loadNibNamed:@"ProfileViewHeader" owner:self options:nil];

    [self setHeaderView]; 
}
  • 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-25T13:12:01+00:00Added an answer on May 25, 2026 at 1:12 pm

    I was right – the table was trying to fill itself from an array that had not yet been filled (it was of 0 size). The solution a dirty hack; initialize it with spaces then use replaceatindexwith and then reload the table.

    Thanks for the help

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

Sidebar

Related Questions

I have a table view which i want to populate with the results (XML)
On each cell of my table view I want to have a bar that
I have a DetailsView control that I want to populate with a data table.
I have a table view that I am customizing and I am adding a
I have a table view that is managed by an NSFetchedResultsController. I am having
I have an MVC application view that is generating quite a large HTML table
I have a self referencing table in Oracle 9i, and a view that gets
I have a Pages table that stores all my view urls and this table
I am writing an iPhone application and I have a table view that is
i have a method that will populate a datatable with the data from a

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.