我有类似于下面的 CFObject 返回方法
-(CFMutableAttributedStringRef)getAttStrForArray:(NSArray*)substrings forString:(NSString*)aStr
{
CFMutableAttributedStringRef as3 = CFAttributedStringCreateMutable(NULL, 0);
CFAttributedStringBeginEditing(as3);
CTFontRef font = CTFontCreateWithName(CFSTR("HelveticaNeue-Bold"), 12.5, NULL);
CFAttributedStringReplaceString(as3, CFRangeMake(0, 0), (__bridge CFStringRef)aStr);
......
CFAttributedStringEndEditing(as3);
//CFRelease(as3);
return as3;
}
在这里,我遇到了内存泄漏,CFRelease(as3);
因为它是一个返回方法,所以我没有释放该对象。有没有办法解决内存泄漏?