Re: NSMutableData capacity
Re: NSMutableData capacity
- Subject: Re: NSMutableData capacity
- From: Jason Teagle <email@hidden>
- Date: Wed, 23 May 2012 19:41:42 +0100
- Organization: Organised Bytes Software
Is there an easy way to figure out the capacity of a NSMutableData
>object - that is the number of bytes that can be written to the data
object without causing it to reallocate the internal buffer or
>invalidating the base pointer to the internal buffer?
Can you not track the capacity yourself? Unless I'm missing something,
if you use
+dataWithCapacity:some_capacity
or
-initWithCapacity:some_capacity
to guarantee it has the capacity (but not necessarily allocated yet)
followed by
-initWithLength:some_capacity
or
-setLength:some_capacity
to guarantee the allocated length = capacity so far, surely thereafter
you would know its capacity and could keep track of it based on any
changes you make to the data / length / capacity yourself?
I appreciate that if you didn't create the NSMutableData in the first
place or you don't have complete control over who else puts data in to
it then you can't track it like this, but your post didn't say if you
had full control so I'm only guessing.
--
Jason Teagle
_______________________________________________
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