Re: Help with NSData dataWithContentsOfURL
Re: Help with NSData dataWithContentsOfURL
- Subject: Re: Help with NSData dataWithContentsOfURL
- From: Michael Ash <email@hidden>
- Date: Thu, 4 Feb 2010 00:21:08 -0500
On Wed, Feb 3, 2010 at 1:46 PM, Charles Srstka <email@hidden> wrote:
> On Feb 3, 2010, at 8:26 AM, cocoa-dev wrote:
>
>> Thanks Graham, here's what I'm thinking. The documents for my app are fileWrappers. Before the document is saved for the first time I can copy the files to a temp folder and during a save move them into the fileWrapper. I guess I need to just abandon the whole NSData idea altogether. Too bad.
>
> If you use NSFileWrapper’s initWithURL:options:error method, and then send it -serializedRepresentation, you should be able to get an NSData. But be careful when doing this, because as has already been mentioned, a directory could contain far more data than will fit in RAM.
Why is everybody so worried about loading an excessive amount of data
if it's a directory, but not if it's a file? HFS+ is capable of
holding files over a billion gigabytes long, which you're going to
have a certain amount of trouble squeezing into RAM. (Or onto any kind
of storage, for that matter.)
If you know that your data will fit into RAM, then you can read it all
at once. If you're not certain, then you must read it in pieces.
Whether the data in question is a single file or a directory of files
doesn't influence this decision at all.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden