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

The Archive Base Latest Questions

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

My app needs to get data from a webpage that is in XML format.

  • 0

My app needs to get data from a webpage that is in XML format. I am using XMLReader to do this and the function works great when there is internet access, however the specific line

NSArray *arr = [XMLReader objectsForXMLData:receivedData error:parseError]; 

crashes when there is no internet. I want the app to print out an error message when there is no internet. Thus i am using **parseError as an indicator. However, i am unsure why the app crashes when it executes this line. I posted the function below. Thank you for all of your help in advance.

NSDateFormatter *dateFmt = [[NSDateFormatter alloc] init];
dateFmt.timeStyle = NSDateFormatterNoStyle;
dateFmt.dateFormat = DATADATEFRMT; // @"yyyy-MM-dd";
NSMutableString *urlStr = [NSMutableString stringWithString:[DATASRCWCAT stringByAppendingString:cat]];
category = cat;
NSLog(@"cate = %@",cat);
[urlStr appendFormat:@"%@%@%@%@", DATAPRD, dataPeriod, DATASTDATE, [dateFmt stringFromDate:currDate]];
NSLog(@"dataPeriod = %@", [dateFmt stringFromDate:currDate]);
NSString *urlString = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

//NSLog(@"URL to obtain data: %@", urlString);

self.crimeid = cat;

// Get the data in xml format and parse
NSData *receivedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
NSError **parseError = nil;
NSArray *arr = [XMLReader objectsForXMLData:receivedData error:parseError]; // <---- crashes here with no internet access.
//NSLog(@"array = %@", [arr objectAtIndex:1]);
self.crimeDataArray = arr;
  • 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-24T03:21:00+00:00Added an answer on May 24, 2026 at 3:21 am

    Check for the presence of ‘receivedData’ before using.

    // Get the data in xml format and parse
    
    NSData *receivedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
    
    if ( receivedData )  // Will only get here if there's data
    {
      NSError **parseError = nil;
      NSArray *arr = [XMLReader objectsForXMLData:receivedData error:parseError]; // <---- crashes here  with no internet access.
      //NSLog(@"array = %@", [arr objectAtIndex:1]);
      self.crimeDataArray = arr;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application is fetching data from a Xml file on a webpage. That date
I have a form data from an iphone app that needs to send HTTP
I've got an app that implements a command object pattern to get data from
I have a C# application that needs to get variable-length data passed back from
My silverlight app needs to get back to the host from whence it came
The app I'm writing needs to get information from a remote database and then
I have a new rails app which needs to access data from a legacy
I have created an App that gets data from Web Services on an In
I have a Django app that needs to pull the follower_count information from several
I´m writing an app which needs to get its content from a website whenever

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.