DotMac

プログラムに関する覚え書き等

NSFileWrapper

How to create directory file wrapper


//ファイルラッパの作成

NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initDirectoryWithFileWrappers:NULL ] autorelease];

//データを追加する

[wrapper   addFileWrapper:aWrapper ];

[wrapper   addFileWrapper:anotherWrapper ];

[wrapper addRegularFileWithContents:aData preferredFilename:@"aData"];



How to decode file wrapper


NSDictionary* aDic  = [wrapper fileWrappers];


NSFileWrapper* aWrapper;

NSFileWrapper* anotherWrapper;

aWrapper = [aDic objectForKey:@"aWrapper's name.rtfd"];

anotherWrapper  = [aDic objectForKey:@"anotherWrapper's name.rtfd"];



data1 = [aWrapper serializedRepresentation];

data2  = [anotherWrapper serializedRepresentation];


data3 = [[aDic objectForKey:@"aData"] regularFileContents];

 

Parting Words (著作権, 連絡先情報, etc.)