• 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: NSString memory management question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString memory management question


  • Subject: Re: NSString memory management question
  • From: Uli Kusterer <email@hidden>
  • Date: Wed, 23 Apr 2008 02:46:28 +0200


Am 23.04.2008 um 00:25 schrieb Rick Mann:

I wrote a routine that creates a CFStringRef from some USB calls. I use it like this:

	NSString* s = (NSString*) createStringDescriptor(dev, stringIndex);
	[mSerialNumberDisplay setStringValue: [s lowercaseString]];
	[s release];

Two main questions: am I right to release the bridged NSString* s? and, what happens in -lowercaseString? How does that get released?


Calling release on a CFString follows the same rules as calling it on an NSString*, and is equivalent to calling CFRelease(). Be careful, though, if you get a CFString or OSString from IOKit ... someone there apparently wasn't told about the rules in the rest of CoreFoundation... they don't follow the Create/Copy naming scheme consistently, and instead have weird phrases in the docs about "consuming a refcount" and things like that.

But apart from that, the rules in the CoreFoundation docs apply, so assuming you're using a CFStringCreateXXX call, yes, you should release this string.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

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: NSString memory management question
      • From: Rick Mann <email@hidden>
References: 
 >NSString memory management question (From: Rick Mann <email@hidden>)

  • Prev by Date: [ANN] TransactionKit, Lockless Multi-Reader, Multi-Writer Transaction Capable Hash Tables
  • Next by Date: Master-Detail binding in User Defaults
  • Previous by thread: Re: NSString memory management question
  • Next by thread: Re: NSString memory management question
  • Index(es):
    • Date
    • Thread