macOS/iOS API解説

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

目次

initWithPath:

ファイルパスからファイルラッパを初期化して返します
-(id)initWithPath:(NSString *)path:

解説

ファイルパスからファイルラッパを初期化して返します。

返り値

( id )

ファイルラッパー

引数

( NSString * )path

パス

フレームワーク

ApplicationKit

クラス

NSFileWrapper

Instance Methods

使用可能

10.0

参照

- setPreferredFilename:
- filename
- fileAttributes

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
    //テキストアタッチメント
    NSTextAttachment *theAttachment;
    //ファイルラッパー
    NSFileWrapper *theWrapper = [[[NSFileWrapper alloc] initWithPath:[[NSBundle mainBundle]
                                    pathForResource:@"image" ofType:@"tiff"]] autorelease];
    theAttachment = [[[NSTextAttachment alloc] initWithFileWrapper:theWrapper] autorelease];
    //テキストビューのテキストストレージに追加
    [[myOutlet textStorage] appendAttributedString:
                    [NSAttributedString attributedStringWithAttachment:theAttachment]];
}

@end