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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:34:07+00:00 2026-06-01T05:34:07+00:00

I’m pulling data into a UITableView via an XML feed from a WordPress site.

  • 0

I’m pulling data into a UITableView via an XML feed from a WordPress site. I wanted to display the table with an image if the post contained one and a default image if it did not. So in my

- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName

method, I have an if statement that looks like this:

if ([elementname isEqualToString:@"content:encoded"]) {
    NSString *firstImageURL = [self getFirstImageUrl:currentStory.content];
    currentStory.imageURL = firstImageURL;
    UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString: firstImageURL]]];
    currentStory.image = image;
}

This calls getFirstImageURL, which looks like this:

-(NSString *)getFirstImageUrl: (NSString *) html {
    NSScanner *theScanner;
    NSString *imageURL = nil;

    theScanner = [NSScanner scannerWithString: html];

    // find start of tag
    [theScanner scanUpToString: @"<img" intoString: NULL];
    if ([theScanner isAtEnd] == NO) {

        [theScanner scanUpToString: @"src=\"" intoString: NULL];
        NSInteger newLoc2 = [theScanner scanLocation] + 5;
        [theScanner setScanLocation: newLoc2];

        // find end of tag
        [theScanner scanUpToString: @"\"" intoString: &imageURL];
    }

    return imageURL;
}

Everything works as it should, but loading the table takes about 5 to 6 seconds and can sometimes take up to 10 seconds, which is not desirable. I was wondering if there is anything I can do to speed up the process of grabbing the first photo.

UPDATE

So after more investigation, it appears that the bottleneck I’m seeing has nothing to do with me downloading images. In fact the actual downloading of images takes no longer than 2 seconds consistently. It looks like the bottleneck happens when I download the RSS feed:

NSData *data = [[NSData alloc] initWithContentsOfURL:url]; 

This consistently takes the longest.

2012-03-30 14:35:11.506 gbllc[883:3203] inside grabDataForFeed
2012-03-30 14:35:11.510 gbllc[883:3203] reached loadXMLByURL
2012-03-30 14:35:11.512 gbllc[883:3203] after stories alloc

**** 5 seconds ****

2012-03-30 14:35:16.568 gbllc[883:3203] after initWithContentsOfURL
2012-03-30 14:35:16.570 gbllc[883:3203] after initWithData
2012-03-30 14:35:16.573 gbllc[883:3203] about to parse

*** I now parse the XML and download images, takes 2 seconds ***

2012-03-30 14:35:18.066 gbllc[883:3203] Parsed successfully

Right after I alloc my data object, I grab the data for parsing. So I guess my original question is no longer valid and I should probably ask if there’s a faster way to grab the initial data for parsing or if I should change my model and try to use json or something?

  • 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-01T05:34:08+00:00Added an answer on June 1, 2026 at 5:34 am

    That’s because you’re downloading the image data itself over the network. You need to offload that and do it asynchronously. Have an NSOperationQueue where you can queue up the image download to happen on a separate thread.

    Here’s a great example of doing just that: http://davidgolightly.blogspot.com/2009/02/asynchronous-image-caching-with-iphone.html

    • 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
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
I am currently running into a problem where an element is coming back from
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&#8217;Everest What PHP function

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.