NSMutableString *string = [[NSMutableString alloc] init]; NSRange effectiveRange = NSMakeRange(0, 0); do { NSDictionary *results = [nonMutableString attributesAtIndex:NSMaxRange(effectiveRange) effectiveRange:&effectiveRange]; if ([results objectForKey:NSAttachmentAttributeName]) [string appendString:[[results objectForKey:NSAttachmentAttributeName] string]]; else [string appendString:[[nonMutableString attributedSubstringFromRange:effectiveRange] string]]; } while (NSMaxRange(effectiveRange) < [nonMutableString length]);