title: EXC_BAD_ACCESS on NSString sizeWithFont
body: <p>I am not sure what is going on anymore. I have tried so many things to for me to figure out whats going on on this specific line of code that is causing a EXC_BAD_ACCESS.
  I tried enabled NSZombies but it didn't help me any. Here is the code:</p>
  
  <pre><code>- (int)linesFromText:(NSString *)string withFont:(UIFont *)font andSize:(CGSize)size {
      NSArray *splitString = [string componentsSeparatedByString:@" "];
      NSMutableArray *allLines = [NSMutableArray array];
      NSMutableString *line = [NSMutableString string];
      NSString *word;
      NSString *fakeLine;
      for (int i = 0; i &lt; splitString.count; i++) {
  
          word = [splitString objectAtIndex:i];
          fakeLine =  [NSString stringWithFormat:@"%@%@ ",line, word];
          //NSLog(@"line %@, font %@",fakeLine,font);
  
          ////THIS IS THE LINE CAUSING THE EXC_BAD_ACCESS
          CGSize lineSize = [fakeLine sizeWithFont:font];
  
          if (lineSize.width &lt;= size.width) {
              [line appendFormat:@"%@ ", word];
          } else {
              [allLines addObject:[line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
              line = [NSMutableString string];
              [line appendFormat:@"%@ ", word];
          }
  
  
      }
      [allLines addObject:[line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
      return allLines.count;
  }
  </code></pre>
  
  <p>This is driving me crazy cause it only happens on the new iphone 5 when you scroll through the days to fast in the app I built. Here is a link to the application in the store:</p>
  
  <p><a href="http://itunes.apple.com/us/app/id543324451?mt=8" rel="nofollow">http://itunes.apple.com/us/app/id543324451?mt=8</a></p>
  
  <p>if you have an iphone 5 you can see what I mean. iphone 4 doesn't do this.</p>
  
  <p>This code is being called in a UITableViewCell's layoutSubviews and is there to help size the frame of a Custom Attributed label that uses TTTAttributedLabel (https://github.com/mattt/TTTAttributedLabel).</p>
  
  <p>I also tried to enable "Gaurd malloc to try give me more details but my XCode gives me this error:</p>
  
  <p>dyld: could not load inserted library '/usr/lib/libgmalloc.dylib' because image not found</p>
  
  <p>which if I look in /usr/lib that file is a sym link to a file that does exist in the same directory:
  libgmalloc.dylib -> libgmalloc.B.dylib</p>
  
  <p>I am running out of ideas here and thought it might be the UIFont getting released to soon and then it not being available so I put references in the UITableViewCell to hold the UIFont until the end of that Cell's life.</p>
  
  <p>I have also searched around the internet and haven't found that much on this specifics.</p>
  
  <p>Also here is an image of my stack trace from debugger:</p>
  
  <p><a href="http://i.stack.imgur.com/gWC5L.png" rel="nofollow">http://i.stack.imgur.com/gWC5L.png</a></p>
  
  <p>Any ideas?
  Did I provide enough info?</p>
  
  <p>Thanks </p>