Using NSAttributedString is actually using different class :) However I advise you to prepare it with NSMutableAttributedString and then store non-mutable version as it is easy to read. Anyway some untested code should look like:
NSMutableAttributedString* message = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"1 word 2 word"] attributes:nil];
[message addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, 1)];
[message addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(8, 1)];
Also you can directly append NSAttributedString ' s with desired properties instead of setting them with range:
NSMutableAttributedString* message = [[NSMutableAttributedString alloc] init];
//set text
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@"1" attributes:@{
NSFontAttributeName : [UIColor greenColor]
}]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@" word"]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@"2" attributes:@{
NSFontAttributeName : [UIColor redColor]
}]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@" word"]];