| Home 目次>Foundation>NSCoder このサイトはこちらに移転しました。 | |
decodeValueOfObjCType:at:
オブジェクティブCタイプの値をデコードします
-(void) decodeValueOfObjCType:(const char *)valueType
at:(void *)data
【返り値】 | |
| void | なし |
| 【パラメータ】 | |
| valueType | 値タイプ |
| data | データ |
【解説】
オブジェクティブCタイプの値をデコードします。
【valueType】
"i"または@encode(int) 整数
@encode(BOOL)
【例文】
#import "MyView.h"
@implementation MyView
// アンアーカイブするときの手順の記述
- ( id )initWithCoder:(NSCoder *)decoder
{
NSLog( @"initWithCoder" );
[ super initWithCoder:decoder];
[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
{
NSLog( @"encodeWithCoder" );
[ super encodeWithCoder:encoder];
[encoder encodeValueOfObjCType: @encode ( int ) at:&intVal];
[encoder encodeValueOfObjCType: @encode ( BOOL ) at:&boolVal];
[encoder encodeArrayOfObjCType: @encode ( float ) count: 1 at:&floatVal];
return ;
}
@end
![]() | |
この記事を評価してください。
| Home 目次>Foundation>NSCoder | 修正日2007.3.22 |