Objective c 类别中的核心文本泄漏

Objective c 类别中的核心文本泄漏,objective-c,ios,memory-leaks,core-text,objective-c-category,Objective C,Ios,Memory Leaks,Core Text,Objective C Category,我找到了NSAttributedString的一个类别,它们返回矩形的高度,该矩形包含给定宽度的属性字符串本身。不幸的是,仪器显示这里面有漏洞。你能告诉我它在哪里吗 @interface NSAttributedString (Height) - (CGFloat)boundingHeightForWidth:(CGFloat)inWidth; @end @implementation NSAttributedString (Height) - (CGFloat)boundingHe

我找到了NSAttributedString的一个类别,它们返回矩形的高度,该矩形包含给定宽度的属性字符串本身。不幸的是,仪器显示这里面有漏洞。你能告诉我它在哪里吗

@interface NSAttributedString (Height)
    - (CGFloat)boundingHeightForWidth:(CGFloat)inWidth;
@end

@implementation NSAttributedString (Height)

- (CGFloat)boundingHeightForWidth:(CGFloat)inWidth
{
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFMutableAttributedStringRef)self); 
    CGSize suggestedSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(inWidth, CGFLOAT_MAX), NULL);
    CFRelease(framesetter);
    return suggestedSize.height ;
}
@end

有时静态分析和仪器会报告泄漏的误报。从你的分类来看,它似乎不应该有任何泄漏,所以我认为你可以忽略这一点