Re: How to create a GUID?
Re: How to create a GUID?
- Subject: Re: How to create a GUID?
- From: "Sean McBride" <email@hidden>
- Date: Mon, 8 Sep 2008 11:00:51 -0400
- Organization: Rogue Research
On 9/6/08 7:51 PM, Clark Cox said:
>The original works with both GC and non-GC, while the version with
>autorelease will leak under GC (because the string is never
>CFRelease'd). In order to work with both runtimes, either use the
>original, or do this:
>
>- (NSString *)uuid
>{
> CFUUIDRef uuidRef = CFUUIDCreate(NULL);
> CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef);
> CFRelease(uuidRef);
> return [NSMakeCollectable(uuidStringRef) autorelease];
>}
One last correction: CFUUIDCreate() may return null, and one can't pass
null to CFRelease(). So an "if (uuidRef)" is needed. (You can pass
null to NSMakeCollectable, but not to CFMakeCollectable).
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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