On Apr 23, 2009, at 3:42 PM, Todd Heberlein wrote:

Many of the Cocoa object allocation methods automatically do an autorelease before returning the pointer to the object, so I can call something like:

foo( [NSString stringWithCString: "bar" encoding: NSASCIIStringEncoding] );

and then not worry about memory leakage. Is the same true with Core Foundation calls? For example, will

foo2( CFSTR("bar") ); or
foo2 ( CFStringCreateWithCString(NULL, "bar", kCFStringEncodingASCII) );

leak memory?

You could just:

foo2 ( [(NSString *)CFStringCreateWithCString(NULL, "bar", kCFStringEncodingASCII) autorelease] );

Charles
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to