I want to use Mantle framework (https://github.com/github/Mantle) to support NSCoding for my class with struct property:
typedef struct {
int x;
int y;
} MPoint;
typedef struct {
MPoint min;
MPoint max;
} MRect;
@interface MObject : MTLModel
@property (assign, nonatomic) MRect rect;
@end
@implementation MObject
@end
But when I tried to [NSKeyedArchiver archiveRootObject:obj toFile:@"file"];
its crashed in MTLModel+NSCoding.m, in - (void)encodeWithCoder:(NSCoder *)coder
on line
case MTLModelEncodingBehaviorUnconditional:
[coder encodeObject:value forKey:key];
Does Mantle supports c-struct encoding (and also decoding) or I've need to custom implementing NSCoding protocol for such classes?
It was easier than I thought:
+encodingBehaviorsByPropertyKey
Sample: