Re: cString deprecated!
Re: cString deprecated!
- Subject: Re: cString deprecated!
- From: Dustin Voss <email@hidden>
- Date: Fri, 6 Sep 2002 06:01:40 -0700
On Thursday, September 5, 2002, at 05:04 AM, Rosyna wrote:
Ack, at 9/4/02, Dustin Voss said:
I'd actually use the following code:
id string;
CFStringRef cfstring;
cfstring = CFStringCreateWithCString (NULL, theCString, encoding);
string = [self initWithString:(NSString*)cfstring];
Why self? If you do have a method named initWithString in self, then
it's named incorrectly. [NSString
stringWithString:(NSString*)cfstring];
I'm sorry, I didn't include enough context. This code would be for an
"initWithCString" method in an NSString category. The return value
shouldn't be auto-released, so I don't call "stringWithString".
CFRelease (cfstring);
This is *very* bad. You *must* check for NULL cause CFRelease has this
lame thing where it calls abort or something if you pass it NULL. Even
though you can free a NULL.
Oh? I didn't know that. Thanks.
return string; // or [string autorelease] if this is a stringWith...
method.
reverse that.
--
Dustin
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.