title: NSMutableAttributedString initWithData: causing EXC_BAD_ACCESS on rotation
body: <p>I display different types of contents in a <code>tableview</code> and calculate the height of each cell using different custom methods, in <code>heightForRowAtIndexPath</code>.</p>
  
  <p>One of these custom methods implies converting some html in an <code>NSMutableAttributedString</code>, and then calculating the height of this <code>NSMutableAttributedString</code>.<br>
  For html conversion I use the new <code>initWithData:</code> method.</p>
  
  <p>All works perfectly except when I rotate the screen => I've got an exc_bad_access every time.</p>
  
  <p>Using Instruments / Zombies, I've been able lo locate the error, and in fact it's this <code>initWithData:</code>.</p>
  
  <p>(When I remove this method and create a "simple" <code>NSMutableAttributedString</code> with <code>initWithString</code>, I can change orientation as many time as I want, no <code>crash</code> anymore).</p>
  
  <p>Any idea why?</p>
  
  <p>(By the way, my project use ARC)</p>
  
  <hr>
  
  <p>Instrument / Zombie screenshot :
  <img src="https://i.stack.imgur.com/R1j45.png" alt="enter image description here"></p>
  
  <hr>
  
  <p>Custom method called in <code>heightForRowAtIndexPath</code> :</p>
  
  <p>&lt; UtilitiesForFrontEndUI <code>heightForFacebookAttributedText</code>: ></p>
  
  <pre><code>+(CGFloat)heightForFacebookAttributedText:(NSString *)attributedText withWidth:(CGFloat)width
  {
      NSAttributedString *formatedText = [self formatRawFacebookContentForFrontEndRichTextContents:attributedText];
      CGRect rect= [formatedText boundingRectWithSize:CGSizeMake(width, 1000) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
      return ceilf(rect.size.height);
  }
  </code></pre>
  
  <hr>
  
  <p>Custom method using the initWithData for html to <code>NSMutableAttributedString</code> conversion :</p>
  
  <p>&lt; UtilitiesForFrontEndUI <code>formatRawFacebookContentForFrontEndRichTextContents:</code> ></p>
  
  <pre><code>+(NSAttributedString *)formatRawFacebookContentForFrontEndRichTextContents:(NSString *)stringToFormat
  {
      // THIS GENERATE EXC_BAD_ACCESS ON DEVICE ROTATION (WORKS IF NO ROTATION)
      NSData *dataContent = [stringToFormat dataUsingEncoding:NSUTF8StringEncoding];
      NSMutableAttributedString *richTxtContent = [[NSMutableAttributedString alloc] initWithData:dataContent options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil];
  
      NSRange myRange;
      myRange.location = 0;
      myRange.length = richTxtContent.length;
  
      [richTxtContent addAttributes:[self commonAttributesForFrontEndRichText] range:myRange];
  
      return richTxtContent;
  }
  </code></pre>
  
  <p>If I replace initWithData by a simple initWithString no more exc_bad_access</p>
  
  <pre><code>+(NSAttributedString *)formatRawFacebookContentForFrontEndRichTextContents:(NSString *)stringToFormat
  {   
      // THIS WORKS (NO MORE ROTATION CRASH)
      NSMutableAttributedString *richTxtContent = [[NSMutableAttributedString alloc]initWithString:stringToFormat];
  
      NSRange myRange;
      myRange.location = 0;
      myRange.length = richTxtContent.length;
  
      [richTxtContent addAttributes:[self commonAttributesForFrontEndRichText] range:myRange];
  
      return richTxtContent;
  }
  </code></pre>