Re: NSMutableData capacity
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