discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableString -initWithFormat appends to existing text


From: David Chisnall
Subject: Re: NSMutableString -initWithFormat appends to existing text
Date: Wed, 18 Apr 2018 16:31:01 +0100

On 18 Apr 2018, at 16:28, Riccardo Mottola <riccardo.mottola@libero.it> wrote:
> 
> As far as I know, no. you can read per character, per bytes, by sized chunks. 
> But not per dat. You could write an extension yourself if needed.
> 
> However, a very quick way is to slurp the whole file in a string and split in 
> an NSArray with -componentsSeparatedByString:
> I have used that with files of GBytes, provided your system has memory.

It’a also worth noting that, on a 64-bit system, it can sometimes be very 
efficient to mmap the entire file and then lazily construct NSString instances 
that use the provided buffer.  The file won’t all be read if you don’t have 
enough memory, and when memory becomes scarce the underlying string storage 
will be evicted and re-read on demand, though the NSString instances will 
remain around.

David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]