On Jul 21, 2011, at 1:01 PM, Wilker wrote:

> I updated to Lion yesterday, but I'm having an issue now with [NSData
> dataWithContentsOfFile]

> Before Lion, it really works well and fast, even on Wifi external drive
> (through Airport Extreme), but now it get's really slow... I did some
> checks, and now its reading the entire file... instead of just read 128kb
> (start and end). Anyone have an ideia on why its happening now? And how to
> make it works as before on Snow Leopard?

>From the Foundation release notes 
><http://developer.apple.com/library/mac/#releasenotes/Cocoa/Foundation.html>:

> Safe File Mapping for NSData
> Before Mac OS 10.7, specifying NSDataReadingMapped (or NSMappedRead) for 
> -initWithContentsOfFile:options:error: would cause NSData to always attempt 
> to map in the specified file. However, in some situations, mapping a file can 
> be dangerous. For example, when NSData maps a file from a USB device or over 
> the network the existence of said file can't be guaranteed for the lifetime 
> of the object. Accessing the NSData's bytes after the mapped file disappears 
> will likely cause unpredictable crashes in your application.
> 
> For applications linked on Mac OS 10.7 or later, NSDataReadingMapped will now 
> only map the requested file if it can determine that mapping the file will be 
> relatively safe. To reflect this change, NSDataReadingMapped has been 
> deprecated and is now an alias for NSDataReadingMappedIfSafe.
> 
> The methods -dataWithContentsOfMappedFile: and -initWithContentsOfMappedFile: 
> have been deprecated. In the very rare event that your application needs to 
> map a file regardless of safety, you may use the NSDataReadingMappedAlways 
> option.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to