macOS/iOS API解説

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

目次

initWithRTFDFileWrapper:documentAttributes:

ファイルラッパーから属性付き辞書を初期化して返します
-(id)initWithRTFDFileWrapper:(NSFileWrapper *)wrapper:
                  documentAttributes:(NSDictionary **)docAttributes:

解説

ファイルラッパーから属性付き辞書を初期化して返します。

返り値

( id )

文字列

引数

( NSFileWrapper * )wrapper

ファイルラッパー

( NSDictionary ** )docAttributes

文書辞書

フレームワーク

ApplicationKit

クラス

NSAttributedStringAdditions

Instance Methods

使用可能

10.1

参照

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
//ファイルラッパ
NSFileWrapper *theWrapper;

NSDictionary *dic = [[NSDictionary alloc] init];

//開けるファイル拡張子の配列
NSArray      *fileTypes    = [ NSArray arrayWithObjects : @"rtfd",@"RTFD",nil ];
//OpenPanelを作る
NSOpenPanel  *opPanel       = [ NSOpenPanel openPanel ];

//OpenPanelの結果のボタン番号
int		  opRet;
     
//OpenPanelでファイル選択   
opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか
                                     file : @"Documents" //どのどのファイルを選択しておくか
                                    types : fileTypes ];//選べるファイルタイプ

if ( opRet == NSOKButton ) {  // OPENPanelのボタンがOKなら

//ファイルから読み込む
theWrapper = [[[NSFileWrapper alloc] initWithPath:[opPanel filename]] autorelease];


//
[[myOutlet textStorage] appendAttributedString:
            [[NSAttributedString alloc] initWithRTFDFileWrapper:theWrapper documentAttributes:&dic]];
            

NSLog([dic description]);
    }

}

@end