I'm trying to cut the length of an NSString without splitting the last word with this method:

```
// cut a string by words
- (NSString* )stringCutByWords:(NSString *)string toLength:(int)length;
{
// search backwards in the string for the beginning of the last word
while ([string characterAtIndex:length] != ' ' && length > 0) {
    length--;
}

// if the last word was the first word of the string search for the end of the word
if (length <= 0){
    while ([string characterAtIndex:length] != ' ' && length > string.length-1) {
        length++;
    }
}

// define the range you're interested in
NSRange stringRange = {0, length};

// adjust the range to include dependent chars
stringRange = [string rangeOfComposedCharacterSequencesForRange:stringRange];

// Now you can create the short string
string = [string substringWithRange:stringRange];

return [NSString stringWithFormat:@"%@...",string];
}

```

now my question is:
Is there a build-in way in objective-c or cocoa-touch which i did not see or else is there a "nicer" way to do this because iam not very happy with this solution.

greetings and thanks for help
C4rmel