本文介绍了如何发布CTFramesetter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用CoreText,我确实有一个很大的泄漏,但是我不知道为什么会发生。因此,这是我的代码段:

I am using CoreText in my app and i have a really huge leak but i cant fnd out why it happens. so here is the snippet of my code:

 _framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)_mAttributedString);

CFDictionaryRef frameOptionsDictionary = (CFDictionaryRef)[self frameOptionsDictionary];

_frame = CTFramesetterCreateFrame(_framesetter,
                                CFRangeMake(0, _mAttributedString.length),
                                path,
                                frameOptionsDictionary);

CFRelease(_framesetter), _framesetter = NULL;

如您所见,我正在释放CTFramesetter ...但是应用程序泄漏,并且仪器向我显示是CTFramesetter导致的。那么我应该如何释放它呢?

As you can see, i am releasing me CTFramesetter... but app leaks, and instruments show me that CTFramesetter causes that. So how should i release it?

推荐答案

0)确保没有失败:

assert(_mAttributedString);
assert(0 == _framesetter);
_framesetter = CTFramesetterCreateWithAttributedString(
                             (CFAttributedStringRef)_mAttributedString);

CFDictionaryRef frameOptionsDictionary =
                   (CFDictionaryRef)[self frameOptionsDictionary];

assert(path);
assert(0 == _frame);
_frame = CTFramesetterCreateFrame(_framesetter,
                                CFRangeMake(0, _mAttributedString.length),
                                path,
                                frameOptionsDictionary);

CFRelease(_framesetter), _framesetter = NULL;

这篇关于如何发布CTFramesetter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 15:00