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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:22:10+00:00 2026-06-09T21:22:10+00:00

For now I am parsing a XML file like the example from Apple (LazyTableImages).

  • 0

For now I am parsing a XML file like the example from Apple (LazyTableImages). Everything works fine. I’d like to add a real-time search (UISearch) which has to parse another XML file (specially programmed for the search). How can I parse this file without freezing the screen?

  • 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-09T21:22:11+00:00Added an answer on June 9, 2026 at 9:22 pm

    You use a GCD and dispatch a block to do this while parsing in the background (and maybe showing a spinner). Your XML parser delegate should be looking at a “cancel” flag, so if the user does something like hit cancel or the back button, you cancel the xml parsing immediately and allow the current operation to stop.

    EDIT: So you will have an ivar to hold the NSXMLParser, and a method in your class that is called when the parsing is complete:

    NSXMLParser *parser;
    NSString *searchTerm;
    id results; // some mutable collection that the parser stores things into
    
    - (void)parseFinished:(id)result; // result can be an array or dictionary, whatever you want
    
    when the user has entered some text and you want to search:
    
    searchTerm = ....; // set it
    parser = [NSXMLParser alloc] init....];
    parsedItems = ....
    
    dispatch_async(dispatch_get_global_queue(0,0), ^
      {
        BOOL ret = [parser parse];
        id myResultObject;
    
        if(ret == YES) {
            // your delegate methods have populated parsedItems now
            search through them using searchTerm
            create and fill in myresultObject, some collection/string/number whatever
        }
        // nil myResultObject means that parser failed
        dispatch_async(dispatch_get_main_queue(), ^[self parseFinished:myResultObject];} );
    } );
    

    If the user types cancel (suppose XML object is huge, and it takes many seconds to parse), then you would in the action method simply send

    [parser abortParsing];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've used following code for parsing XML file in c++. http://www.codeproject.com/Articles/176236/Parsing-an-XML-file-in-a-C-C-program . Now I
I have student.xml file and am parsing this file using SAX Parser and now
I'm parsing an xml file from an url and it displays the content correctly.here
I have a script file for parsing through a SQLite database. I now need
I'm trying to read in an xml file which looks like this <?xml version=1.0
I am using SAX to parse an XML file I'm pulling from the web.
i have a xml file and i am parsing it with DOM. ` <media:group>
so I have a list of <div> 's in an xml file. I'm parsing
I'm parsing an XML file with LibXML and need to sort the entries by
I'm having a bit of an issue. I'm parsing a large xml file using

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.