• 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: NSData Questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData Questions


  • Subject: Re: NSData Questions
  • From: Nick Zitzmann <email@hidden>
  • Date: Sat, 8 Aug 2009 16:15:25 -0600


On Aug 8, 2009, at 3:45 PM, Eric Hermanson wrote:

1. Is it more efficient to malloc a uint8_t array and call NSData 'init no copy', rather than pass in an array allocated with a fixed length on the stack to the init method that makes a copy of the bytes?

If you need to allocate larger amounts of memory than what is typically available on the stack, then you should always do the former. Otherwise, you ought to try doing both and just go with what Shark tells you is fastest. Complete this sentence: Premature optimization is...


2. Does NSMutableData's implementation simply just cast it's internal bytes to const in the 'bytes' method, or does it internally copy the bytes into a new autoreleased NSData and return the 'bytes' for that copy, for example?

What are you trying to accomplish? If you're trying to modify the data's contents, then use -mutableBytes instead.


Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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


References: 
 >NSData Questions (From: Eric Hermanson <email@hidden>)

  • Prev by Date: Re: NSArrayController access between nib files
  • Next by Date: Re: Giving the Root Object of an Outline View a Different Background Color.
  • Previous by thread: NSData Questions
  • Next by thread: Re: NSData Questions
  • Index(es):
    • Date
    • Thread