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

Re: NSMutableData capacity


  • Subject: Re: NSMutableData capacity
  • From: Wade Tregaskis <email@hidden>
  • Date: Wed, 23 May 2012 19:30:05 -0700

> Can you not track the capacity yourself? Unless I'm missing something, if you use
>
>    +dataWithCapacity:some_capacity

The docs note that this doesn't necessarily pre-allocate the given capacity.  You can test that trivially by asking for a capacity of several gigabytes.

In a nutshell, there's no way to "lock" the underlying bytes of NSMutableData (or NSMutableString, or anything else like them).  If you mutate them via method calls, you need to reset any interior pointers you may have.  Strictly speaking you should reset your interior pointers every time you invoke any method on them, since they're technically free to re-arrange their internals however they like, even for what are [externally] non-mutating methods.

If there's a performance concern, using IMP caching.  The cost of the function call to retrieve the bytes pointer is really trivial.
_______________________________________________

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

  • Follow-Ups:
    • Re: NSMutableData capacity
      • From: Jason Teagle <email@hidden>
    • Re: NSMutableData capacity
      • From: Jens Alfke <email@hidden>
References: 
 >NSMutableData capacity (From: Andreas Grosam <email@hidden>)
 >Re: NSMutableData capacity (From: Jason Teagle <email@hidden>)

  • Prev by Date: Re: Debugging uiscrollview not responding to user
  • Next by Date: Re: PDFThumbnailView Problem (kind of)
  • Previous by thread: Re: NSMutableData capacity
  • Next by thread: Re: NSMutableData capacity
  • Index(es):
    • Date
    • Thread