Objective c NSTextView在文本之间插入图像

Objective c NSTextView在文本之间插入图像,objective-c,cocoa,macos,nstextview,nsimage,Objective C,Cocoa,Macos,Nstextview,Nsimage,是否可以将图像(而不是背景图像)插入到NSTextView? 比如: Hi :) How are you? 嗨:)你好吗? 它应该显示一个“笑脸”图像。我有一个NSTextView和一个NSImage将NSImage插入到NSTextView中: NSImage * pic = [[NSImage alloc] initWithContentsOfFile:@"/Users/Anne/Desktop/Sample.png"]; NSTextAttachmentCell *attachmentCe

是否可以将图像(而不是背景图像)插入到
NSTextView
? 比如:

Hi :) How are you? 嗨:)你好吗?
它应该显示一个“笑脸”图像。我有一个
NSTextView
和一个
NSImage

将NSImage插入到NSTextView中:

NSImage * pic = [[NSImage alloc] initWithContentsOfFile:@"/Users/Anne/Desktop/Sample.png"];
NSTextAttachmentCell *attachmentCell = [[NSTextAttachmentCell alloc] initImageCell:pic];
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
[attachment setAttachmentCell: attachmentCell ];
NSAttributedString *attributedString = [NSAttributedString  attributedStringWithAttachment: attachment];
[[textView textStorage] appendAttributedString:attributedString];
在头文件中:

IBOutlet id textView;

非常感谢,还有一个问题是,是否有任何方法可以添加更多控件,例如,如果我想在用户想要传输文件时添加进度条,谢谢!您知道如何提供单元格图像的拖放功能吗?默认情况下,如果我将其拖动到Finder,它会创建一个空文本文件。您找到如何在nstextview中添加复选框或其他内容了吗?我没有查找复选框,我只需要插入图像,我相信,使用nstextview应该是可行的