//NSTextView显示图片
NSTextAttachment *atacchment = [[NSTextAttachment alloc]init];
//用户的图片路径
atacchment.image = [NSImage imageNamed:@"a.png"] ;
//图片在textview中显示的大小
atacchment.bounds = CGRectMake(0, 0, 20, 20);
NSAttributedString *attributedStr = [[NSAttributedString alloc]initWithString:@""];
attributedStr = [NSAttributedString attributedStringWithAttachment:atacchment];
//textStorage装载内容的容器,继承自NSMutableAttributedString,其里面保存的东西决定了textview的富文本显示方式
[self.textView.textStorage appendAttributedString:attributedStr];