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 />