Ipad 为什么可以';我不能在应用程序不崩溃的情况下释放我的CTFramesetter吗?

Ipad 为什么可以';我不能在应用程序不崩溃的情况下释放我的CTFramesetter吗?,ipad,memory-management,ios,nsattributedstring,core-text,Ipad,Memory Management,Ios,Nsattributedstring,Core Text,我正在构建一个iPad应用程序,它可以从NSAttribute字符串中呈现文本页面。我创建了一个框架设置器,如下所示: - (void)renderTextFromAttributedString:(NSAttributedString *)string { CFAttributedStringRef attrString = (CFAttributedStringRef)string; framesetter = CTFramesetterCreateWithAttribute

我正在构建一个iPad应用程序,它可以从NSAttribute字符串中呈现文本页面。我创建了一个框架设置器,如下所示:

- (void)renderTextFromAttributedString:(NSAttributedString *)string
{
    CFAttributedStringRef attrString = (CFAttributedStringRef)string;
    framesetter = CTFramesetterCreateWithAttributedString(attrString);
    CFRelease(attrString);
。。。然后,代码逐个添加新的页面视图,并将framesetter指针传递给每个视图以呈现每个页面,直到没有字符为止:

- (void)drawNewPage
{
    CTSinglePageView *newPage = [[CTSinglePageView alloc] initWithFrame:newFrame];
    newPage.delegate = self;
    [newPage renderWithFramesetter:framesetter fromIndex:currentIndex margins:self.margins];
    [self addSubview:newPage];
    [newPage release];
    currentPage ++;
。。。等等。现在这一切都很好,呈现页面并完美地显示格式化文本。然而,在渲染过程结束时,我仍然有一个需要清除的CTFramesetter,因此我可以构建下一组页面。然而,如果我这样做

    if(framesetter) CFRelease(framesetter);
在进程结束时,CTFramesetter被释放(显然),程序崩溃!但是如果我不释放framesetter,我最终会得到相当大的内存泄漏,程序就会退出

为什么释放会导致崩溃?启用NSZombieEnabled后,我收到的错误消息是:

*-[NSConcreteAttributedString release]:发送到已解除分配实例0xed20270的消息


给予的任何帮助都会得到极大的回报!我们现在正面临一个最后期限,如果我现在能增加一笔赏金,我会的任何回答好的人都将在两天时间窗口结束后获得奖金。:-)

您确定要释放ATRTSTRING吗?这看起来不对。我想知道这是否是在以后发布framesetter时导致崩溃的原因。

更多的代码显示更多的结构将是有帮助的。你完全正确。很抱歉,我不得不回去检查,这个问题是几个月前提出的,现在我忘了关闭它!对属性字符串不应该被释放,因为我没有保留它。该应用程序已提交并获得批准:-),但感谢您的帮助!