classNameEncodedForTrueClassName:
指定したクラスのアーカイブに使われるクラス名を返します
-(NSString *)classNameEncodedForTrueClassName:(NSString *)trueName:
解説
指定したクラスのアーカイブに使われるクラス名を返します。
返り値
( NSString * )
クラス名
引数
( NSString * )trueName
名前
フレームワーク
Foundation
クラス
NSArchiver
Instance Methods
使用可能
10.0
参照
- encodeClassName:intoClassName:
例文
#import "MyObject.h" #import "MyView.h" @implementation MyObject - (IBAction)slider:(id)sender { } - (IBAction)archive:(id)sender { NSArchiver *archiver = [[NSArchiver alloc] initForWritingWithMutableData: [NSMutableData data]]; //セーブパネル設定 NSSavePanel *savePanel = [NSSavePanel savePanel]; //拡張子codeにする [savePanel setRequiredFileType:@"code"]; //ウインドウのコンテンツビュー丸ごとアーカイブ switch ([savePanel runModalForDirectory:NSHomeDirectory() file:@""]) { case NSOKButton: [archiver encodeRootObject:[window contentView]]; NSLog([archiver classNameEncodedForTrueClassName:@"NSView"]); break; } } - (IBAction)unarchive:(id)sender { //拡張子codeのファイルを選ぶ NSArray *fileTypes = [NSArray arrayWithObject:@"code"]; //オープンパネル設定 NSOpenPanel *openPanel = [NSOpenPanel openPanel]; //ホームディレクトリで開く [openPanel setDirectory:NSHomeDirectory()]; // if ([openPanel runModalForTypes:fileTypes]) { id aView = [NSUnarchiver unarchiveObjectWithFile: [openPanel filename]]; [(NSWindow *)window setContentView:aView]; } } @end