macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

decodeArrayOfObjCType:count:at:

INDEX>Foundation>NSCoder>

オブジェクティブCタイプで配列をデコードします
-(void)decodeArrayOfObjCType:(const char *)itemType:
               count:(NSUInteger)count:
               at:(void *)address:

解説

オブジェクティブCタイプで配列をデコードします。

返り値

( void )

なし

引数

( const char * )itemType

アイテムタイプ

( NSUInteger )count

カウント

( void * )address

ポインタ

クラス

NSCoder

Instance Methods

使用可能

10.0

参照

- decodeValuesOfObjCTypes:

例文

#import "MyView.h"

@implementation MyView

//アンアーカイブするときの手順の記述
- (id)initWithCoder:(NSCoder *)decoder
{

    intVal = 20;
    boolVal = NO;
    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
{
    intVal = 10;
    boolVal = YES;
    
    [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