Search code examples
iosexc-bad-accesscore-text

CTFramesetterCreateWithAttributedString EXC_BAD_ACCESS


I use core text to draw sth and it receives EXC_BAD_ACCESS problem in case of


CTFramesetterCreateWithAttributedString((CFAttributedStringRef)immutableContent);

I also print immutableContent which is a NSAttributedString: enter image description here

The problem here is when this happens, I don't know how to debug it. I guess there is sth wrong with the NSAttributedString, but I don't know how to fix it. Besides, the method used to create the NSAttributedString works in another project. So why I am confused~~

thanks!


Solution

  • my code and works fine

    NSMutableAttributedString* attrStrWithLinks = [self.attributedText mutableCopy];
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attrStrWithLinks);
    

    self.attributedText - NSAttributedString