@implementation NSMutableString (NSMutableStringHypenAdditions) 

-(void) addSoftHypens;
{
NSMutableAttributedString *string = [[[NSMutableAttributedString alloc] initWithString:self] autorelease];
NSRange wordRange = NSMakeRange([string length], 0);

NSString *shy = [NSString stringWithFormat: @"%C", 0xad];

do {
wordRange = [string doubleClickAtIndex:wordRange.location-2];
NSUInteger hyphenIndex = NSMaxRange(wordRange);
do {
hyphenIndex = [string lineBreakByHyphenatingBeforeIndex:hyphenIndex withinRange:wordRange];
if (hyphenIndex!=NSNotFound) {
[self insertString:shy atIndex:hyphenIndex];
}
} while (hyphenIndex!=NSNotFound);
} while (wordRange.location>2);
}

@end