NStextview note:
we use textview for collecting the logs from terminal or equipment port .
NSAttributedstring *attributedstr = [NSAttributedString alloc] initiwithstring:(NSString *)str attributes:(NSMutableDictionary *)dic];
[textview textstorage] appendattributedstring:(NSAttributedstring *) attributedstring; --appendstr
code:
NSString *str = @"hello, soelsdkfj sld sodfl asl a我饿谁说大幅拉升哦 is 快乐的佛 i 阿斯科利大事佛阿胶alkydi 哦啊时间来考试的offer流口水的麻烦i 哦文件佛拉风i 就哦 i 啊三闾大夫破额外附加";
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];
[dicsetObject:[NSColor redColor] forKey:NSForegroundColorAttributeName];
[dicsetObject:[NSColor blueColor] forKey:NSBackgroundColorAttributeName];
NSAttributedString *attri = [[NSAttributedString alloc] initWithString:str attributes:dic];
[[_textview textStorage] appendAttributedString:attri];