• 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: Unclear on -initWithBytesNoCopy:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unclear on -initWithBytesNoCopy:


  • Subject: Re: Unclear on -initWithBytesNoCopy:
  • From: Dave Keck <email@hidden>
  • Date: Sat, 03 Mar 2012 14:28:29 -0500

> The documentation of -[NSData initWithBytesNoCopy:length:freeWhenDone:] and of -[NSString initWithBytesNoCopy:length:encoding:freeWhenDone:] is unclear about the case where freeWhenDone is NO. The data/string object then does not take ownership of the memory buffer, so the question is: How long is the caller obligated to keep the buffer intact?
>
> The two possible answers seem to be
> (a) until the caller releases the NSString object, or
> (b) forever, until the process exits (i.e. only ever use this on constant buffers)

The buffer needs to remain intact until the NSString/NSData object is
deallocated.

_______________________________________________

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: Unclear on -initWithBytesNoCopy:
      • From: Jens Alfke <email@hidden>
References: 
 >Unclear on -initWithBytesNoCopy: (From: Jens Alfke <email@hidden>)

  • Prev by Date: Unclear on -initWithBytesNoCopy:
  • Next by Date: Re: Unclear on -initWithBytesNoCopy:
  • Previous by thread: Unclear on -initWithBytesNoCopy:
  • Next by thread: Re: Unclear on -initWithBytesNoCopy:
  • Index(es):
    • Date
    • Thread