NSCoder:decodeValueOfObjCType:at:
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


(C) 2000-2009 Satoshi Oomori.
[Apple]

Google
Webwww.oomori.com
Apple_Store_40x120

[ad:Usual day in Japan]

この記事を評価してください。 

良い 

間違いがある 説明がわかりにくい 例文がわかりにくい  

Home 目次>Foundation>NSCoder
修正日2007.3.22