objective c - loading big xml file -


What I'm trying to load a large file server, but it always seems to be very slow to load you me Methods can suggest, how to load faster, then 200k objects?

  data printing Details: (Ansdita *) data = 0x08e51d80 151341098 bytes NSURLRequest * urlRequest = [NSURLRequest requestWithURL: url]; NSOperationQueue * queue = [[NSOperationQueue alloc] init]; [NSURLConnection sendAsynchronousRequest: urlRequest queue: queue completionHandler: ^ (NSURLResponse * reaction, NSData * data, NSError * error) {if (error) {NSLog (@ "error,% @", [error localized description]); } Else {NSLog (@ "% @", [[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding]); }}];  

Two point:

  1. You can use the file Instead of catching the entire NSData in the memory output stream for network requests, for example, AFNetworking supports such options.
  2. You can use the SAX parser with stream support to separate your data from the file, again, avoid loading full XML memory. For example, parsing NSXMLParser support stream.

NSXMLParser example of setting is here:

  NSInputStream * fileStream = [NSInputStream Inputstrym with url: temporaryXMLFileURL]; NSXMLPers * Parser = [[NSX Parser Alok] Init Withstream: Filestream]; Parser.delegate = yourParserDelegate; BOOL result = [parser paras];  

You can use your parsing & amp; There are many examples on the Internet from Apple, where there is an object acceleration code in the class which adopts NSXMLParserDelegate .

Please note that these tips speed will not be the Internet from its large file Download , my approach is entirely dependent on your connection speed only your application memory Help reduce footprint (hence, due to reducing the risk of your app due to memory pressure by iOS).


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -