I am writing a function to calculate the final attributtedString index in rect,
But there seems to be some kind of memory leak, Please help me fix this.
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributtedString);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, rect);
CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(currentIndex, 0), path, NULL);
CFRange frameRange = CTFrameGetVisibleStringRange(frame);
endIndex += frameRange.length;
CFRelease(frame);
CFRelease(path);
CFRelease(framesetter);
early.
source
share