macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

attachmentCell

ハンドルマウスイベントにアイコンを描くために使用されるオブジェクトを返します

解説

ハンドルマウスイベントにアイコンを描くために使用されるオブジェクトを返します。
NSTextAttachmentは、デフォルトでファイルが画像を含むなら、添付ファイルのアイコンまたはその内容を表示するNSTextAttachmentCellを使います。

返り値

( id <NSTextAttachmentCell> )

オブジェクト

引数

フレームワーク

ApplicationKit

クラス

NSTextAttachment

Instance Methods

使用可能

10.0

参照

- fileWrapper
- image (NSCell)
- icon (NSFileWrapper)
- setAttachmentCell:

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
    //テキストアタッチメント
    NSTextAttachment *theAttachment;
    NSTextAttachmentCell *bCell = [[[NSTextAttachmentCell alloc] initImageCell:nil] autorelease];
    //ファイルラッパ
       //テキストアタッチメント
    theAttachment = [[[NSTextAttachment alloc] init] autorelease];
    
    [theAttachment setAttachmentCell:bCell];
    
    NSLog([[theAttachment attachmentCell] className]);
    //
    [[myOutlet textStorage] appendAttributedString:
            [NSAttributedString attributedStringWithAttachment:theAttachment]];
}

@end