Comments for Snippet #45 http://codebeach.org/code/show/45 Comments feed for Snippet #45 en-us Sun, 09 Sep 2007 00:25:11 +0000 Zach S. says: http://codebeach.org/code/show/45 codebeach.org:comment:137 Sorry, but this snippet leaks memory; the reference to the UUID object returned by CFUUIDCreate is lost after this function returns and can never be released. <br /> <br />A Cocoa-friendly implementation could involve a category on NSString: <br /> <br />+ (NSString*)UUIDString { <br /> CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); <br /> CFStringRef stringRef = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); <br /> CFRelease(uuidRef); <br /> <br /> return [(id)stringRef autorelease]; <br />}<br /><br /> Sun, 24 Oct 2010 09:57:18 +0000 Terry Blanchard says: http://codebeach.org/code/show/45 codebeach.org:comment:162 Zach is correct, this does leak memory. But there is an even more Cocoa-friendly method: <br /> <br />[[NSProcessInfo processInfo] globallyUniqueString];<br /><br />