• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSXMLParser useless with HUGE files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXMLParser useless with HUGE files


  • Subject: Re: NSXMLParser useless with HUGE files
  • From: Johan Kool <email@hidden>
  • Date: Wed, 14 Dec 2005 18:39:57 +0000

Hello Matt,

I had some trouble reading in a large file too, although I wasn't
using the XML parser. The following code does chop the text file up in
smaller pieces which I then process. 65536 is a bit arbitrary, but I
figured it was safest to use a number to the power of 2.

You do have to make sure that the last round doesn't trip over the
remainder as your file might not divide to 65536 to an exact number.

Hope this helps.

Johan

// Read a huge file piece by piece
NSData *aHugeFileData = [NSData dataWithContentsOfMappedFile:path];

int count = [aHugeFileData length]/65536;
unsigned char aBuffer[65536];

for (i = 0; i <= count; i++) {
[aHugeFileData getBytes:aBuffer range:NSMakeRange(65536*i, 65536)];
NSString *tempString = [[NSString alloc] initWithBytes:aBuffer
length:65536 encoding:NSASCIIStringEncoding];
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSXMLParser useless with HUGE files (From: Matt Gough <email@hidden>)

  • Prev by Date: Re: NSAppleScript init is really, really slow when attached to gdb?
  • Next by Date: Re: KVO / Core Data question
  • Previous by thread: Re: NSXMLParser useless with HUGE files
  • Next by thread: Re: NSXMLParser useless with HUGE files
  • Index(es):
    • Date
    • Thread