• 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: create NSMutableString with no limit?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: create NSMutableString with no limit?


  • Subject: Re: create NSMutableString with no limit?
  • From: Andy Lee <email@hidden>
  • Date: Sat, 18 Mar 2006 17:48:13 -0500

On Mar 18, 2006, at 5:37 PM, James W. Walker wrote:
What's the right way to create an NSMutableString with no limit on its capacity? The only initialization method listed in the docs is initWithCapacity, and it doesn't say you can pass 0 as the capacity. I can take advantage of toll-free bridging and say (NSMutableString*)CFStringCreateMutable( NULL, 0 ), but there must be a more obvious way.

NSMutableStrings don't have a limit on their capacity. The argument to -initWithCapacity: is just the amount of storage to initially allocate. This way, if you know the string will never grow beyond that amount, it doesn't have to reallocate memory as the string grows. In most cases the performance gain is negligible, but if you're doing tons and tons of appends to the string, it might help.


--Andy

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >create NSMutableString with no limit? (From: "James W. Walker" <email@hidden>)

  • Prev by Date: Re: create NSMutableString with no limit?
  • Next by Date: Re: create NSMutableString with no limit?
  • Previous by thread: Re: create NSMutableString with no limit?
  • Next by thread: Re: create NSMutableString with no limit?
  • Index(es):
    • Date
    • Thread