title: Split a string of text between two UILabels to wrap around image
body: <p>I'm trying to separate a long strong of text between two UILabels in order to wrap around an image. I've re-used and adapted some code left behind by a previous developer on this project which is below...</p>
  
  <p>The String (sequential number words, 1 to 20):</p>
  
  <pre><code>NSString *sampleString = @"One two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty. One two three four five six seven eight nine ten. Eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty.";
  </code></pre>
  
  <p>The spliting method...</p>
  
  <pre><code>-(void)seperateTextIntoLabels:(NSString*) text
  {
      // Create array of words from our string
      NSArray *words = [text componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]];
  
      //Data storage for loop
      NSMutableString *text1 = [[NSMutableString alloc] init];
      NSMutableString *text2 = [[NSMutableString alloc] init];
  
      for(NSString *word in words)
      {
          CGSize ss1 = [[NSString stringWithFormat:@"%@ %@",text1,word] sizeWithFont:descriptionLabel.font constrainedToSize:CGSizeMake(descriptionLabel.frame.size.width, 9999) lineBreakMode:descriptionLabel.lineBreakMode];
  
          if(ss1.height &gt; descriptionLabel.frame.size.height || ss1.width &gt; descriptionLabel.frame.size.width)
          {
              if( [text2 length]&gt;0)
              {
                  [text2 appendString: @" "];
              }
              [text2 appendString: word];
          }
          else {
              if( [text1 length]&gt;0)
              {
                  [text1 appendString: @" "];
              }
              [text1 appendString:word];
          }
  
      }
      descriptionLabel.text = text1;
      descriptionLabelTwo.text = text2;
  
      [descriptionLabel sizeToFit];
      [descriptionLabelTwo sizeToFit];
  
  }
  </code></pre>
  
  <p>It works more-or-less as I'd expect it to, except it's getting confused at the point where the switch happens.</p>
  
  <p><img src="https://i.stack.imgur.com/7ISTZ.png" alt="enter image description here"></p>
  
  <p>Notice the last word in label 1 'One' which is misplaced. This word is also missing from mid-way-through the second label. Other than this issue it seems to work ok otherwise.</p>
  
  <p>Any ideas on what's happening here?</p>
  
  <p>Are there any alternative solutions for this? Please note that I'd rather not use a UIWebView (mostly because of the delay in on-screen rendering).</p>