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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:22:34+00:00 2026-05-23T06:22:34+00:00

Alright. Lets say i have a UITextField where a user can input an url

  • 0

Alright.

Lets say i have a UITextField where a user can input an url such as:

http://foo.bar/foo/bar.asmx

Now, if the application is fed the right URL, it will respond with an NSData with a bytesize of around 450-700 depending on the returning values, the values differ between users. The call takes around a second or so, and the NSXMLParser parses the data within a second aswell.

But whenever we input for example:

http://apple.com/foo/bar.asmx

We recieve an NSData with a bytesize of around 9700. And the parser parses this data through infinity. And i have no idea how to throw the proper errormessage when the user has made input to an invalid url resulting in the NSXMLParser parses for infinity.

We tried using this.

in the

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{

xmlParser = [[NSXMLParser alloc] initWithData:myData];
[xmlParser setDelegate:self];
[xmlParser shouldResolveExternalEntities:YES];
[xmlParser parse];
[self performSelector:@selector(timeOutMyParser:) withObject:nil afterdelay:15];

[xmlParser release];
[connection release];
[myData release];

}

Now, what happens with this code is that the performSelector is never executed since it’s forever running the parsing.

So to summarize:

In order to reduce the number of errors our users can create, we need to stop our current NSXMLParser parser operations if they take to long.

Is there any EASY way to cancel the current parsing operation?

  • 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-23T06:22:34+00:00Added an answer on May 23, 2026 at 6:22 am

    The issue was that the [xmlParser parse] was blocking the main thread, locking everything.

    So instead of

     -(void)connectionDidFinishLoading:(NSURLConnection *)connection
        {
    
        xmlParser = [[NSXMLParser alloc] initWithData:myData];
        [xmlParser setDelegate:self];
        [xmlParser shouldResolveExternalEntities:YES];
        [xmlParser parse];
        [self performSelector:@selector(timeOutMyParser:) withObject:nil afterdelay:15];
    
        [xmlParser release];
        [connection release];
        [myData release];
    
        }
    

    i did this.

    -(void)connectionDidFinishLoading:(NSURLConnection *)connection
    {
    
    xmlParser = [[NSXMLParser alloc]init];
    [xmlParser setDelegate:self];
    [xmlParser shouldResolveExternalEntities:YES];
    
    [self performSelectorInBackground:@selector(someFunction) withObject:xmlParser];
    
    [xmlParser release];
    [connection release];
    [myData release];
    
    }
    

    Where someFunction is something like this.

    -(void)someFunction:(NSXMLParser *)parser
    {
    
    parser = [[NSXMLParser alloc]initWithData:myData];
    [parser setDelegate:self];
    [parser parse];
    
    [parser release];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright. I have several queries <?php // Make a MySQL Connection mysql_connect(mm.hostname.net, user, pass)
Alright so I have recently made the decision to put every string in my
I've written a multi-project .vstemplate file, which works alright, except that the projects have
Alright, so I've looked around the web and haven't been able to find what
Alright, i'm making a small game, and I need to limit my FPS, because,
Alright, so I'm writing this program that essentially batch runs other java programs for
Alright, so I think I'm pretty close to having what I need, but I'm
I'm using sortable to implement a one-dimensional list of widgets. It's working alright, but
tl;dr: I want a high-level introduction to Rails, which covers what I need to
I am using Window 7, when I run my code in local everything is

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.