• 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: What is the life of the c string returned by NSString's UTF8String method?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the life of the c string returned by NSString's UTF8String method?


  • Subject: Re: What is the life of the c string returned by NSString's UTF8String method?
  • From: Wade Tregaskis <email@hidden>
  • Date: Fri, 18 Sep 2009 13:53:38 -0700

Or to avoid a copy and raw memory management, you can also query directly an NSData from the string using -[NSString dataUsingEncoding:NSUTF8StringEncoding] and then use -[NSData bytes] as the returned value for this method is guarantee to have the same life as the NSData object.

Though of course you must then beware the GC.

Wade
_______________________________________________

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


References: 
 >What is the life of the c string returned by NSString's UTF8String method? (From: Stuart Malin <email@hidden>)
 >Re: What is the life of the c string returned by NSString's UTF8String method? (From: Nick Zitzmann <email@hidden>)
 >Re: What is the life of the c string returned by NSString's UTF8String method? (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: getting accessor method info in a different class.
  • Next by Date: Problem with fontDescriptorWithFontAttributes:
  • Previous by thread: Re: What is the life of the c string returned by NSString's UTF8String method?
  • Next by thread: getting accessor method info in a different class.
  • Index(es):
    • Date
    • Thread