123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- //
- // StyleVideoModel.m
- //
- // Created by Steven on 2022/4/12
- // Copyright (c) 2022 __MyCompanyName__. All rights reserved.
- //
- #import "StyleVideoModel.h"
- NSString *const kStyleVideoModelUserId = @"userId";
- NSString *const kStyleVideoModelBrowse = @"browse";
- NSString *const kStyleVideoModelId = @"id";
- NSString *const kStyleVideoModelUpdateTime = @"updateTime";
- NSString *const kStyleVideoModelDescribe = @"describe";
- NSString *const kStyleVideoModelVideoUrl = @"videoUrl";
- NSString *const kStyleVideoModelCreateTime = @"createTime";
- NSString *const kStyleVideoModelAuthStatus = @"authStatus";
- NSString *const kStyleVideoModelCover = @"cover";
- @interface StyleVideoModel ()
- - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
- @end
- @implementation StyleVideoModel
- @synthesize userId = _userId;
- @synthesize browse = _browse;
- @synthesize internalBaseClassIdentifier = _internalBaseClassIdentifier;
- @synthesize updateTime = _updateTime;
- @synthesize describe = _describe;
- @synthesize videoUrl = _videoUrl;
- @synthesize createTime = _createTime;
- @synthesize authStatus = _authStatus;
- @synthesize cover = _cover;
- + (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.userId = [self objectOrNilForKey:kStyleVideoModelUserId fromDictionary:dict];
- self.browse = [[self objectOrNilForKey:kStyleVideoModelBrowse fromDictionary:dict] doubleValue];
- self.internalBaseClassIdentifier = [self objectOrNilForKey:kStyleVideoModelId fromDictionary:dict];
- self.updateTime = [self objectOrNilForKey:kStyleVideoModelUpdateTime fromDictionary:dict];
- self.describe = [self objectOrNilForKey:kStyleVideoModelDescribe fromDictionary:dict];
- self.videoUrl = [self objectOrNilForKey:kStyleVideoModelVideoUrl fromDictionary:dict];
- self.createTime = [self objectOrNilForKey:kStyleVideoModelCreateTime fromDictionary:dict];
- self.authStatus = [self objectOrNilForKey:kStyleVideoModelAuthStatus fromDictionary:dict];
- self.cover = [self objectOrNilForKey:kStyleVideoModelCover fromDictionary:dict];
- }
-
- return self;
-
- }
- - (NSDictionary *)dictionaryRepresentation
- {
- NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
- [mutableDict setValue:self.userId forKey:kStyleVideoModelUserId];
- [mutableDict setValue:[NSNumber numberWithDouble:self.browse] forKey:kStyleVideoModelBrowse];
- [mutableDict setValue:self.internalBaseClassIdentifier forKey:kStyleVideoModelId];
- [mutableDict setValue:self.updateTime forKey:kStyleVideoModelUpdateTime];
- [mutableDict setValue:self.describe forKey:kStyleVideoModelDescribe];
- [mutableDict setValue:self.videoUrl forKey:kStyleVideoModelVideoUrl];
- [mutableDict setValue:self.createTime forKey:kStyleVideoModelCreateTime];
- [mutableDict setValue:self.authStatus forKey:kStyleVideoModelAuthStatus];
- [mutableDict setValue:self.cover forKey:kStyleVideoModelCover];
-
- 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.userId = [aDecoder decodeObjectForKey:kStyleVideoModelUserId];
- self.browse = [aDecoder decodeDoubleForKey:kStyleVideoModelBrowse];
- self.internalBaseClassIdentifier = [aDecoder decodeObjectForKey:kStyleVideoModelId];
- self.updateTime = [aDecoder decodeObjectForKey:kStyleVideoModelUpdateTime];
- self.describe = [aDecoder decodeObjectForKey:kStyleVideoModelDescribe];
- self.videoUrl = [aDecoder decodeObjectForKey:kStyleVideoModelVideoUrl];
- self.createTime = [aDecoder decodeObjectForKey:kStyleVideoModelCreateTime];
- self.authStatus = [aDecoder decodeObjectForKey:kStyleVideoModelAuthStatus];
- self.cover = [aDecoder decodeObjectForKey:kStyleVideoModelCover];
- return self;
- }
- - (void)encodeWithCoder:(NSCoder *)aCoder
- {
- [aCoder encodeObject:_userId forKey:kStyleVideoModelUserId];
- [aCoder encodeDouble:_browse forKey:kStyleVideoModelBrowse];
- [aCoder encodeObject:_internalBaseClassIdentifier forKey:kStyleVideoModelId];
- [aCoder encodeObject:_updateTime forKey:kStyleVideoModelUpdateTime];
- [aCoder encodeObject:_describe forKey:kStyleVideoModelDescribe];
- [aCoder encodeObject:_videoUrl forKey:kStyleVideoModelVideoUrl];
- [aCoder encodeObject:_createTime forKey:kStyleVideoModelCreateTime];
- [aCoder encodeObject:_authStatus forKey:kStyleVideoModelAuthStatus];
- [aCoder encodeObject:_cover forKey:kStyleVideoModelCover];
- }
- - (id)copyWithZone:(NSZone *)zone
- {
- StyleVideoModel *copy = [[StyleVideoModel alloc] init];
-
- if (copy) {
- copy.userId = [self.userId copyWithZone:zone];
- copy.browse = self.browse;
- copy.internalBaseClassIdentifier = [self.internalBaseClassIdentifier copyWithZone:zone];
- copy.updateTime = [self.updateTime copyWithZone:zone];
- copy.describe = [self.describe copyWithZone:zone];
- copy.videoUrl = [self.videoUrl copyWithZone:zone];
- copy.createTime = [self.createTime copyWithZone:zone];
- copy.authStatus = [self.createTime copyWithZone:zone];
- copy.cover = [self.cover copyWithZone:zone];
- }
-
- return copy;
- }
- @end
|