• 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: 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

  • Follow-Ups:
    • Re: NSMutableData capacity
      • From: Wade Tregaskis <email@hidden>
    • Re: NSMutableData capacity
      • From: Fritz Anderson <email@hidden>
References: 
 >NSMutableData capacity (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Strange behavior with App Sandbox and CoreData Document
  • Next by Date: Re: NSMutableData capacity
  • Previous by thread: Re: NSMutableData capacity
  • Next by thread: Re: NSMutableData capacity
  • Index(es):
    • Date
    • Thread