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 哦文件佛拉風(fēng)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];