You can wrap the struct in a NSData
, ie
To encode with archiver
[coder encodeObject:[NSData dataWithBytes:&my_struct length:sizeof(my_struct)]
forKey:@"my_struct"];
and to decode with archiver
NSData *data = [coder decodeObjectForKey:@"my_struct"];
[data getBytes:&my_struct length:sizeof(my_struct)];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…