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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:32:57+00:00 2026-06-12T04:32:57+00:00

My application uses a table that is populated by a dynamic xml feed. I

  • 0

My application uses a table that is populated by a dynamic xml feed. I am also using the pull to refresh code written by Grant Paul to reload the table with new content, if there is some. Thirdly, I am using Apple’s Reachability to determine internet connectivity when reloading the table. My problem is this; If I open the application WITH internet connection, then while the app is running, shut of my internet connection, I then pull to refresh the application and it crashes. Something is happening when the app is switching between Reachable and NotReachable. Below is my code. The app fails with a Thread 6: signal SIGABRT on this line: TFHppleElement *element = [elements objectAtIndex:0];

Here is the error code:

2012-10-02 14:00:03.715 FireCom[2229:1517] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x2d63012 0x21a0e7e 0x2d050b4 0x603f 0xd810d5 0xd81034 0x96213557 0x961fdcee)
libc++abi.dylib: terminate called throwing an exception
(lldb)

Here is the Reachability code:

- (void)loadCallList
{
Reachability* reach = [Reachability reachabilityWithHostname:@"www.apple.com"];
NetworkStatus netStatus = [reach currentReachabilityStatus];

switch (netStatus)
{
    case NotReachable:
    {
        NSLog(@"Access Not Available");

        [pull finishedLoading];
        [self displayInternetMessage];

        break;
    }

    case ReachableViaWWAN:
    {
        NSLog(@"Reachable WWAN");

        // Parse HTML for random ID and create XML link

        NSURL *theURL = [NSURL URLWithString:@"http://www.wccca.com/PITS/"];
        NSData *data = [[NSData alloc] initWithContentsOfURL:theURL];
        xpathParser = [[TFHpple alloc] initWithHTMLData:data];
        NSArray *elements = [xpathParser searchWithXPathQuery:@"//input[@id='hidXMLID']//@value"];
        TFHppleElement *element = [elements objectAtIndex:0];
        TFHppleElement *child = [element.children objectAtIndex:0];
        NSString *idValue = [child content];

        NSString *idwithxml = [idValue stringByAppendingFormat:@".xml"];
        NSString *url = @"http://www.wccca.com/PITS/xml/fire_data_";
        NSString *finalurl = [url stringByAppendingString:idwithxml];

        xmlParser = [[XMLParser alloc] loadXMLByURL:finalurl];

        if (xmlParser.calls.count == 0)
        {
            self.headerHeight = 0.0;
            UIAlertView *noCalls = [[UIAlertView alloc] initWithTitle:@"No Current Calls"
                                                              message:@"There are no current 9-1-1 calls in Clackamas or Washington County."
                                                             delegate:self
                                                    cancelButtonTitle:@"OK"
                                                    otherButtonTitles:nil];

            [noCalls show];
            [noCalls release];
        }
        else
        {
            self.headerHeight = 45.0;
        }

        [callsTableView reloadData];
        [pull finishedLoading];

        break;
    }
    case ReachableViaWiFi:
    {
        NSLog(@"Reachable WiFi");

        // Parse HTML for random ID and create XML link

        NSURL *theURL = [NSURL URLWithString:@"http://www.wccca.com/PITS/"];
        NSData *data = [[NSData alloc] initWithContentsOfURL:theURL];
        xpathParser = [[TFHpple alloc] initWithHTMLData:data];
        NSArray *elements = [xpathParser searchWithXPathQuery:@"//input[@id='hidXMLID']//@value"];
        TFHppleElement *element = [elements objectAtIndex:0];
        TFHppleElement *child = [element.children objectAtIndex:0];
        NSString *idValue = [child content];

        NSString *idwithxml = [idValue stringByAppendingFormat:@".xml"];
        NSString *url = @"http://www.wccca.com/PITS/xml/fire_data_";
        NSString *finalurl = [url stringByAppendingString:idwithxml];

        xmlParser = [[XMLParser alloc] loadXMLByURL:finalurl];

        if (xmlParser.calls.count == 0)
        {
            self.headerHeight = 0.0;

            UIAlertView *noCalls = [[UIAlertView alloc] initWithTitle:@"No Current Calls"
                                                              message:@"There are no current 9-1-1 calls in Clackamas or Washington County."
                                                             delegate:self
                                                    cancelButtonTitle:@"OK"
                                                    otherButtonTitles:nil];

            [noCalls show];
            [noCalls release];
        }
        else
        {
            self.headerHeight = 45.0;
        }

        [callsTableView reloadData];
        [pull finishedLoading];

        break;
    }
}
}
  • 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-12T04:32:58+00:00Added an answer on June 12, 2026 at 4:32 am

    I think I see your problem.

    NSArray *elements = [xpathParser searchWithXPathQuery:@"//input[@id='hidXMLID']//@value"];
    TFHppleElement *element = [elements objectAtIndex:0];
    TFHppleElement *child = [element.children objectAtIndex:0];
    

    You can’t assume elements has a count of at least on 1.


    Update

    Maybe try something like

    NSArray *elements = [xpathParser searchWithXPathQuery:@"//input[@id='hidXMLID']//@value"];
    if (elements.count < 1) {
        // Any needed cleanup
        break;
    }
    
    TFHppleElement *element = [elements objectAtIndex:0];
    TFHppleElement *child = [element.children objectAtIndex:0];
    

    as a fast way out.

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

Sidebar

Related Questions

I have content management system application that uses a polymorphic tree table as the
I am debugging an application that uses an XML file to store data as
I have an iPad application that uses table view controllers to present lists of
I have set up a rails application that uses single table inheritance but I
I added a table to a database that my application uses and wrote some
I'm adding new features to a legacy application written in PHP that uses an
I'm developing a spring application that uses large MySQL tables. When loading large tables,
I have an Android application that uses the Android database to create tables and
My application uses asp.net 4, C# and Entity Framework. My database contains a table
My application uses MS access database to save some sensitive information. Though that information

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.