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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:55:51+00:00 2026-06-11T07:55:51+00:00

Okay so I am having some issues when doing some NSXMLParsing. The parsers are

  • 0

Okay so I am having some issues when doing some NSXMLParsing. The parsers are working fine individually, but when I try to run them asynchronously in the background, only one of them will indicate that it has completed parsing the document.

To explain my full process, it goes as follows

  1. I load 2 webpages using multiple NSURLConnections and NSURLRequests, in the background as to not block the user interface
  2. I then take that data and pass it into an xml parser.
  3. There is a separate XML parser for each webpage, each with its own reference and memory allocated to it.
  4. I then run through the parser as you would normally do, and it looks for specific tags I indicate, yadda yadda, that stuff is all working fine.
  5. The problem comes in when I have the parsers indicate that they have finished, I use the parserDidEndDocument:(NSXMLParser *)parser method to check if the document has finished or not. Unfortunately this method is only called once, so I do not know if both parsers have completed or not.

My code is this:

When the connections complete

-(void) connectionDidFinishLoading:(NSURLConnection *)connection {
    if (connection == actConnection) {
        [self processSynopsis]; // initiate synopsis parser
    } else if (connection == castConnection) {
        [self processCast]; // initiate cast parser
    }
}

Allocating and starting synopsis parser

-(void) processSynopsis {
    actParser = [[NSXMLParser alloc] initWithData:actData];
    [actParser setDelegate:self];
    [actParser parse];
}

Allocating and starting cast parser

-(void) processCast {
    castParser = [[NSXMLParser alloc] initWithData:castData];
    [castParser setDelegate:self];
    [castParser parse];
}

Checking if the parser terminated

-(void) parserDidEndDocument:(NSXMLParser *)parser {

    if (parser == actParser) {
        NSLog(@"ended act %@",parser);
    } else if (parser == castParser) {
        NSLog(@"ended cast %@",parser);
    }
}

The parserDidEndDocument method will only be called once for some reason. Anyone see anything wrong or have had this problem before. Thanks for any help in advance!

  • 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-11T07:55:52+00:00Added an answer on June 11, 2026 at 7:55 am

    NSLog is a simple front end to NSLogv, which does the actual logging work. According to the documentation:

    Output from NSLogv is serialized, in that only one thread in a process can be doing the writing/logging described above at a time. All attempts at writing/logging a message complete before the next thread can begin its attempts.

    I’m not sure how to interpret “can begin”. This could mean that an attempt to log something while NSLogv is running will be ignored. Therefore if your second parser finishes very soon after the first parser the log message will not be sent.

    Try the @synchronized() directive to prevent the two threads from stepping on each other. Something like this:

    -(void) parserDidEndDocument:(NSXMLParser *)parser {
        @syncronized(self) {
            if (parser == actParser) {
                NSLog(@"ended act %@",parser);
            } else if (parser == castParser) {
               NSLog(@"ended cast %@",parser);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay. I'm having some conceptual issues with a WCF service i want to create.
Okay, I'm having some serious issues here. I'm new to this site, and new
Okay I got some good advice for Mobile Detection but still having an issue
I am having some trouble with my code. Okay so I have an ASPx
Okay this is my first WPF app and I am having a hard run
Okay, I feel a bit foolish for having to ask this but I guess
I having some issues with a client of mine. I've built (not designed) an
Okay, I am wondering having clear web.config file could be good but you know
Okay I am having some problems with being able to change bitmaps when a
Okay, I'm having some headaches regarding the Friend and Protected Friend qualifiers. The 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.