123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- //
- // MaterialList.m
- //
- // Created by Steven on 2023/5/14
- // Copyright (c) 2023 __MyCompanyName__. All rights reserved.
- //
- #import "MaterialList.h"
- NSString *const kMaterialListAdviseStudyTimeSecond = @"adviseStudyTimeSecond";
- NSString *const kMaterialListContent = @"content";
- NSString *const kMaterialListKnowledgePointId = @"knowledgePointId";
- NSString *const kMaterialListUpdateTime = @"updateTime";
- NSString *const kMaterialListId = @"id";
- NSString *const kMaterialListCourseTypeCode = @"courseTypeCode";
- NSString *const kMaterialListSn = @"sn";
- NSString *const kMaterialListType = @"type";
- NSString *const kMaterialListName = @"name";
- NSString *const kMaterialListKnowledgePointMaterialRelationId = @"knowledgePointMaterialRelationId";
- @interface MaterialList ()
- - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
- @end
- @implementation MaterialList
- @synthesize adviseStudyTimeSecond = _adviseStudyTimeSecond;
- @synthesize content = _content;
- @synthesize knowledgePointId = _knowledgePointId;
- @synthesize updateTime = _updateTime;
- @synthesize materialListIdentifier = _materialListIdentifier;
- @synthesize courseTypeCode = _courseTypeCode;
- @synthesize sn = _sn;
- @synthesize type = _type;
- @synthesize name = _name;
- @synthesize knowledgePointMaterialRelationId = _knowledgePointMaterialRelationId;
- + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
- {
- return [[self alloc] initWithDictionary:dict];
- }
- - (instancetype)initWithDictionary:(NSDictionary *)dict
- {
- self = [super init];
-
- // This check serves to make sure that a non-NSDictionary object
- // passed into the model class doesn't break the parsing.
- if(self && [dict isKindOfClass:[NSDictionary class]]) {
- self.adviseStudyTimeSecond = [self objectOrNilForKey:kMaterialListAdviseStudyTimeSecond fromDictionary:dict];
- self.content = [self objectOrNilForKey:kMaterialListContent fromDictionary:dict];
- self.knowledgePointId = [self objectOrNilForKey:kMaterialListKnowledgePointId fromDictionary:dict];
- self.updateTime = [self objectOrNilForKey:kMaterialListUpdateTime fromDictionary:dict];
- self.materialListIdentifier = [self objectOrNilForKey:kMaterialListId fromDictionary:dict];
- self.courseTypeCode = [self objectOrNilForKey:kMaterialListCourseTypeCode fromDictionary:dict];
- self.sn = [self objectOrNilForKey:kMaterialListSn fromDictionary:dict];
- self.type = [self objectOrNilForKey:kMaterialListType fromDictionary:dict];
- self.name = [self objectOrNilForKey:kMaterialListName fromDictionary:dict];
- self.knowledgePointMaterialRelationId = [self objectOrNilForKey:kMaterialListKnowledgePointMaterialRelationId fromDictionary:dict];
- }
-
- return self;
-
- }
- - (NSDictionary *)dictionaryRepresentation
- {
- NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
- [mutableDict setValue:self.adviseStudyTimeSecond forKey:kMaterialListAdviseStudyTimeSecond];
- [mutableDict setValue:self.content forKey:kMaterialListContent];
- [mutableDict setValue:self.knowledgePointId forKey:kMaterialListKnowledgePointId];
- [mutableDict setValue:self.updateTime forKey:kMaterialListUpdateTime];
- [mutableDict setValue:self.materialListIdentifier forKey:kMaterialListId];
- [mutableDict setValue:self.courseTypeCode forKey:kMaterialListCourseTypeCode];
- [mutableDict setValue:self.sn forKey:kMaterialListSn];
- [mutableDict setValue:self.type forKey:kMaterialListType];
- [mutableDict setValue:self.name forKey:kMaterialListName];
- [mutableDict setValue:self.knowledgePointMaterialRelationId forKey:kMaterialListKnowledgePointMaterialRelationId];
- return [NSDictionary dictionaryWithDictionary:mutableDict];
- }
- - (NSString *)description
- {
- return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
- }
- #pragma mark - Helper Method
- - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
- {
- id object = [dict objectForKey:aKey];
- if ([object isKindOfClass:[NSNumber class]]) {
- NSNumber *number = object;
- object = [number stringValue];
- }
- return [object isEqual:[NSNull null]] ? nil : object;
- }
- #pragma mark - NSCoding Methods
- - (id)initWithCoder:(NSCoder *)aDecoder
- {
- self = [super init];
- self.adviseStudyTimeSecond = [aDecoder decodeObjectForKey:kMaterialListAdviseStudyTimeSecond];
- self.content = [aDecoder decodeObjectForKey:kMaterialListContent];
- self.knowledgePointId = [aDecoder decodeObjectForKey:kMaterialListKnowledgePointId];
- self.updateTime = [aDecoder decodeObjectForKey:kMaterialListUpdateTime];
- self.materialListIdentifier = [aDecoder decodeObjectForKey:kMaterialListId];
- self.courseTypeCode = [aDecoder decodeObjectForKey:kMaterialListCourseTypeCode];
- self.sn = [aDecoder decodeObjectForKey:kMaterialListSn];
- self.type = [aDecoder decodeObjectForKey:kMaterialListType];
- self.name = [aDecoder decodeObjectForKey:kMaterialListName];
- self.knowledgePointMaterialRelationId = [aDecoder decodeObjectForKey:kMaterialListKnowledgePointMaterialRelationId];
- return self;
- }
- - (void)encodeWithCoder:(NSCoder *)aCoder
- {
- [aCoder encodeObject:_adviseStudyTimeSecond forKey:kMaterialListAdviseStudyTimeSecond];
- [aCoder encodeObject:_content forKey:kMaterialListContent];
- [aCoder encodeObject:_knowledgePointId forKey:kMaterialListKnowledgePointId];
- [aCoder encodeObject:_updateTime forKey:kMaterialListUpdateTime];
- [aCoder encodeObject:_materialListIdentifier forKey:kMaterialListId];
- [aCoder encodeObject:_courseTypeCode forKey:kMaterialListCourseTypeCode];
- [aCoder encodeObject:_sn forKey:kMaterialListSn];
- [aCoder encodeObject:_type forKey:kMaterialListType];
- [aCoder encodeObject:_name forKey:kMaterialListName];
- [aCoder encodeObject:_knowledgePointMaterialRelationId forKey:kMaterialListKnowledgePointMaterialRelationId];
- }
- - (id)copyWithZone:(NSZone *)zone
- {
- MaterialList *copy = [[MaterialList alloc] init];
-
- if (copy) {
- copy.adviseStudyTimeSecond = [self.adviseStudyTimeSecond copyWithZone:zone];
- copy.content = [self.content copyWithZone:zone];
- copy.knowledgePointId = [self.knowledgePointId copyWithZone:zone];
- copy.updateTime = [self.updateTime copyWithZone:zone];
- copy.materialListIdentifier = [self.materialListIdentifier copyWithZone:zone];
- copy.courseTypeCode = [self.courseTypeCode copyWithZone:zone];
- copy.sn = [self.sn copyWithZone:zone];
- copy.type = [self.type copyWithZone:zone];
- copy.name = [self.name copyWithZone:zone];
- copy.knowledgePointMaterialRelationId = [self.knowledgePointMaterialRelationId copyWithZone:zone];
- }
-
- return copy;
- }
- @end
|