我在网上找到了一个创建通用唯一标识符 (UUID) 的小方法。xCode 静态分析器告诉我,此方法正在泄漏内存,它在下面的代码中标记。
有人能告诉我编写这段代码的正确方法是什么,这样就不会出现内存泄漏吗?
+(NSString *)createUUID
{
// Create universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
// Get the string representation of CFUUID object.
//leak here
NSString *uuidStr = (__bridge NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject) ;
CFRelease(uuidObject);
return uuidStr;
}