- (NSMutableAttributedString *)infoText:(NSIndexPath *)indexPath { NSArray *settingArray = [self getArray]; id specificSetting = [settingArray objectAtIndex:indexPath.row]; // [(BMSettings *)[settingArray objectAtIndex:indexPath.row] detail]; NSString *settingDetails = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@", [specificSetting detail]]]; NSString *setToON = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@", [specificSetting setOn]]]; NSString *setToOFF = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@", [specificSetting setOff]]]; // NSString *infoText = @"settingDetails \n\nTurned ON\n settingON \n\nTurned OFF\n settingOFF"; NSMutableAttributedString *infoText = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ \n\n%@ \n\n%@", settingDetails, setToON, setToOFF]]; [infoText addAttribute:NSFontAttributeName value:[UIFont preferredFontForTextStyle:UIFontTextStyleBody] range:[settingDetails rangeOfString:settingDetails]]; [infoText addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:[settingDetails rangeOfString:settingDetails]]; [infoText addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:[settingDetails rangeOfString:setToON]]; [infoText addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:[settingDetails rangeOfString:setToOFF]]; // **************** code from PSY unadulterated to work with:*********** // [attributedString replaceCharactersInRange:[attributedString.string rangeOfString:@"%@"] withString:message]; // return infoText; }