decodeObject
オブジェクトをデコードします
解説
オブジェクトをデコードします。
返り値
( id )
オブジェクト
引数
フレームワーク
Foundation
クラス
NSCoder
Instance Methods
使用可能
10.0
参照
- encodeBycopyObject:
- encodeByrefObject:
- encodeObject:
例文
#import "MyView.h" @implementation MyView //アンアーカイブするときの手順の記述 - (id)initWithCoder:(NSCoder *)decoder { NSPoint point; NSRect rect; NSSize size; NSMutableData *dat2 = [NSMutableData data]; intVal = 20; boolVal = NO; NSLog(@"initWithCoder"); [super initWithCoder:decoder]; NSLog([decoder decodeObject]); NSLog([decoder decodeObject]); NSLog([NSString stringWithFormat:@"point = %.1f",[decoder decodePoint].x]); NSLog([decoder decodeObject]); NSLog([decoder decodeObject]); dat2 = [decoder decodeDataObject]; point = [decoder decodePoint]; NSLog([NSString stringWithFormat:@"point = %.1f,%.1f",point.x,point.y]); rect = [decoder decodeRect]; NSLog([NSString stringWithFormat:@"rect = %.1f,%.1f,%.1f,%.1f",rect.origin.x,rect.origin.y,rect.size.width,rect.size.height]); size = [decoder decodeSize]; NSLog([NSString stringWithFormat:@"size = %.1f,%.1f",size.width,size.height]); myview = [[decoder decodeObject] retain]; [decoder decodeValueOfObjCType:@encode(int) at:&intVal]; NSLog([NSString stringWithFormat:@"intVal = %d",intVal]); [decoder decodeValueOfObjCType:@encode(BOOL) at:&boolVal]; if (boolVal){ NSLog(@"YES"); }else{ NSLog(@"NO"); } [decoder decodeArrayOfObjCType:@encode(float) count:1 at:&floatVal]; return self; } //アーカイブするときの手順の記述 - (void)encodeWithCoder:(NSCoder *)encoder { NSMutableData *dat = [NSMutableData data]; NSLog(@"encodeWithCoder"); intVal = 10; boolVal = YES; [super encodeWithCoder:encoder]; [encoder encodeObject:@"obj"]; [encoder encodeBycopyObject:@"encodeBycopyObject"]; [encoder encodePoint:NSMakePoint(100,100)]; [encoder encodeByrefObject:@"encodeByrefObject"]; [encoder encodeConditionalObject:@"ConditionalObject"]; [encoder encodeDataObject:dat]; [encoder encodePoint:NSMakePoint(10,10)]; [encoder encodeRect:NSMakeRect(0,0,10,10)]; [encoder encodeSize:NSMakeSize(30,30)]; [encoder encodeObject:self]; [encoder encodeValueOfObjCType:@encode(int) at:&intVal]; [encoder encodeValueOfObjCType:@encode(BOOL) at:&boolVal]; [encoder encodeArrayOfObjCType:@encode(float) count:1 at:&floatVal]; return; } @end