1

When I was working with the Cocoa part of my project, I could do this:

[[self.aTextView textStorage] appendAttributedString:attrstg]; // textStorage is a mutable attributed string
// release attrstg and all its components
[attrstg release];
[dict release];
[paragStyle release];
[colorHSV release];

But in the iOS counterpart, using Core Foundation attributed strings, I get bad-access exceptions unless I hang onto the strings which I am appending AND their attributes dictionaries AND the style components that went into the attributes dictionaries.

I have made the necessary changes to hang onto everything in iOS and it works OK — but what’s going on? Why the difference between Cocoa and iOS here? Nothing in the class refs for either attributed-string class mentions this issue. Am I missing something that will cause problems later?

Wienke
  • 3,723
  • 27
  • 40
  • Please show the code where you create the appended string and its attributes. – Costique Apr 16 '12 at 06:38
  • For the iOS version (CFAttributedString), see the first 2 blocks of the answer here: [http://stackoverflow.com/questions/10149389/re-autorotating-scrolling-bulleted-indented-uiscrollview-with-attributed-str/10149530#10149530]. For the Cocoa version (NSAttributedString), see the answer here: [http://stackoverflow.com/questions/5810706/how-to-programmatically-add-bullet-list-to-nstextview/9023020#9023020]. – Wienke Apr 17 '12 at 00:00

0 Answers0