87365

NSXMLParser on iOS8 - NSXMLParser does not support reentrant parsing

I have NSXMLParser problem, and i tried iOS8 NSXMLParser crash this topic, but i really did not get the solution.

I am creating another NXSMLParser delegate and setting its delegate in another class.

Could you please tell me what to do exactly, step by step? I am so confused.

Here is my code;

These lines of codes are inside the STXMLParser

STXMLParser2 *stXMLParser2 = [[STXMLParser2 alloc]init]; stXMLParser2.xmlParser = [[NSXMLParser alloc] initWithData:responseLoader.xmlData]; [stXMLParser2.xmlParser setDelegate:self]; [stXMLParser2.xmlParser setShouldResolveExternalEntities:YES]; [stXMLParser2.xmlParser parse];

Answer1:

You can try this code:

dispatch_queue_t reentrantAvoidanceQueue = dispatch_queue_create("reentrantAvoidanceQueue", DISPATCH_QUEUE_SERIAL); dispatch_async(reentrantAvoidanceQueue, ^{ STXMLParser2 *stXMLParser2 = [[STXMLParser2 alloc]init]; stXMLParser2.xmlParser = [[NSXMLParser alloc] initWithData:responseLoader.xmlData]; [stXMLParser2.xmlParser setDelegate:self]; [stXMLParser2.xmlParser setShouldResolveExternalEntities:YES]; [stXMLParser2.xmlParser parse]; }); dispatch_sync(reentrantAvoidanceQueue, ^{ });

Answer2:

I was getting the same error and it turned out that the problem was due to calling a UI update in the func parserDidEndDocument(parser: NSXMLParser) which does not run on the main thread. After forcing the UI update in that function to run on the main queue, the problem was resolved.

Answer3:

I encountered the same problem recently but it turned out that I had an exception in one of my delegates (KVO problem) and once I fixed that the reentracy error went away. So it might be worth to look for something else if you don't have an obvious multithreading or multiinstance problem.

Recommend

  • PyAudio IOError: [Errno Invalid input device (no default output device)] -9996
  • Why mmap a 4GB file on 32-bit armv7l succeeded?
  • Display input file without print in awk
  • Is it unsafe to mix static and reinterpret cast when casting to and back from void*?
  • SQL Query, Average climbed and pair that has climbed the most peaks
  • SSRS Expression-Sum two fields
  • How to convert 0s to NaNs in certain columns of dataframe in R?
  • Mysql get closest numeric result comparing two columns (lat and long) at same time
  • Sparql query from Dbpedia and another graph returns less results than expected
  • Listbox generates secondary Listbox based on selection
  • Calculating rounded percentage in Shell Script without using “bc”
  • R tbats Model Seasonal Customer Flag No Results
  • Changing co-ordinate system
  • ITextSharp: parse html with cyrillic/international words
  • Grep number extraction
  • How to resolve XmlBeanDefinitionStoreException in Spring MVC while adding mvc:annotation-driven?
  • How to append data to NSKeyedArchive?
  • NSXMLParser parser:parseErrorOccurred: not called on iOS 7
  • add the value in Arraylist in hashmap android
  • Why can I not initialize an array by passing a pointer to a function?
  • Infer constraints for both if and else of type equality
  • Cells become empty after scrolling. (Xcode)
  • How to replace a contour (rectangle) in an image with a new image using Python?
  • How to load HTML in UITextView?
  • Why do I have to use LD_PRELOAD for libcl.2 to use XML::LibXML::Common on HP/UX?
  • Why must we Forward Declare a class and include the corresponding header file in a header file
  • Get XML response value with GDataXML
  • Multilingual set up of codeigniter
  • Is there an HTML code that can make my background picture transparent and my text non-transparent?
  • iOS 6 dateFromString returns wrong date
  • “A GKScore must specify a leaderboard.”
  • Emacs lua-mode issue: (void-function interactively-called-p)
  • remove unicode characters but keep all special and English characters with preg_replace
  • Knockout custom binding handler
  • Question about instantiating object
  • NSScanner Loop Question
  • Pass value from viewmodel to script in zk
  • Eraser for UIBezierPath
  • Compare two NSDates in iPhone
  • Load html files in TinyMce