macOS/iOS API解説

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

目次

updateAttachmentsFromPath:

調査中
-(void)updateAttachmentsFromPath:(NSString *)path:

解説

調査中
テキストアタッチメントを更新します。

返り値

( void )

なし

引数

( NSString * )path

ファイルパス

フレームワーク

ApplicationKit

クラス

NSMutableAttributedString Additions

Instance Methods

使用可能

10.0

参照

- updateFromPath:(NSFileWrapper)

例文

#import "MyObject.h"
//TextViewからこのクラスにdelegateしている
@implementation MyObject
- (void)textView:(NSTextView *)aTextView clickedOnCell:(id <NSTextAttachmentCell>)attachmentCell inRect:(NSRect)cellFrame

{
NSLog([NSString stringWithFormat:@"%.1f,%.1f,%.1f,%.1f",cellFrame.origin.x,cellFrame.origin.y,cellFrame.size.width,cellFrame.size.height]);
}

- (IBAction)myAction:(id)sender
{
    //範囲
    NSRange ran;
    //テキストアタッチメント
    NSTextAttachment *theAttachment;
    //ファイルラッパ
    NSFileWrapper *theWrapper = [[[NSFileWrapper alloc] initWithPath:
            [[NSBundle mainBundle] pathForResource:@"image" ofType:@"tiff"]] autorelease];
            
    //変更可能な属性付き文字列
    NSMutableAttributedString *maStr =[[NSMutableAttributedString alloc]
                    initWithString:@"" attributes:nil];
        
    //テキストアタッチメント
    theAttachment = [[[NSTextAttachment alloc] initWithFileWrapper:theWrapper] autorelease];
    
    maStr = [NSMutableAttributedString attributedStringWithAttachment:theAttachment];
    //
    [[myOutlet textStorage] appendAttributedString:maStr];
            
ran = NSMakeRange(1,3);
[myOutlet insertText:@"<-clich!"];

[myOutlet smartInsertBeforeStringForString:@"sss"
            replacingRange:ran];
            
    //アップデート
    [maStr updateAttachmentsFromPath: [[NSBundle mainBundle] pathForResource:@"image" ofType:@"tiff"]];
            
}

@end