当我做"构建和分析" XCode给了我以下警告:
存储在'字符串'
中的对象的潜在泄漏- (NSString *)getUUID
{
NSString *UUID = [EA_APP_CONSTANT getUserDefaultsValueForKey:@"uniqueID"];
if (!UUID) {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
UUID = [(__bridge NSString*)string stringByReplacingOccurrencesOfString:@"-"withString:@""];
[EA_APP_CONSTANT setUserDefaultsValue:UUID forKey:@"uniqueID"];
}
return UUID;
}
我该如何解决这个问题?
答案 0 :(得分:0)
您需要致电CFRelease(string);
- (NSString *)getUUID
{
NSString *UUID = [EA_APP_CONSTANT getUserDefaultsValueForKey:@"uniqueID"];
if (!UUID) {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
UUID = [(__bridge NSString*)string stringByReplacingOccurrencesOfString:@"-"withString:@""];
[EA_APP_CONSTANT setUserDefaultsValue:UUID forKey:@"uniqueID"];
CFRelease(string);
}
return UUID;
}