// // MyOrderModel.m // DSH // // Created by 张毅成 on 2018/10/8. // Copyright © 2018 WZX. All rights reserved. // #import "MyOrderModel.h" @implementation MyOrderModel + (NSDictionary *)modelContainerPropertyGenericClass { return @{@"orderProductList" : [MyOrderModel class], @"productList" : [MyOrderModel class], @"order" : [MyOrderModel class] }; } + (NSDictionary *)modelCustomPropertyMapper { return @{@"describe" : @"description"}; } - (NSArray *)arrayTypeTitle { return _arrayTypeTitle = @[@"", @"待付款", @"待发货", @"待收货", @"待评价", @"已取消", @"已完成"]; // return _arrayTypeTitle = @[@"", @"待付款", @"待评价", @"已取消"]; } /* 使用runtime进行解档与归档。 */ - (void)encodeWithCoder:(NSCoder *)aCoder { unsigned int count = 0; Ivar *ivarLists = class_copyIvarList([MyOrderModel class], &count);// 注意下面分析 for (int i = 0; i < count; i++) { const char* name = ivar_getName(ivarLists[i]); NSString* strName = [NSString stringWithUTF8String:name]; [aCoder encodeObject:[self valueForKey:strName] forKey:strName]; } free(ivarLists); //一定不要忘了,自己释放。 } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super init]) { unsigned int count = 0; Ivar *ivarLists = class_copyIvarList([MyOrderModel class], &count); for (int i = 0; i < count; i++) { const char* name = ivar_getName(ivarLists[i]); NSString* strName = [NSString stringWithCString:name encoding:NSUTF8StringEncoding]; id value = [aDecoder decodeObjectForKey:strName]; [self setValue:value forKey:strName]; } free(ivarLists); } return self; } @end