This commit is contained in:
Yao
2025-01-11 14:58:16 +08:00
parent f82486e8b0
commit 1095c32599
262 changed files with 62730 additions and 36131 deletions

View File

@@ -0,0 +1,81 @@
//
// PushRecordDataModel.m
//
// Created by on 2025/1/11
// Copyright (c) 2025 zL. All rights reserved.
//
#import "PushRecordDataModel.h"
#import "PushRecordData.h"
NSString *const kPushRecordDataModelData = @"data";
NSString *const kPushRecordDataModelCode = @"code";
@interface PushRecordDataModel ()
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
@end
@implementation PushRecordDataModel
@synthesize data = _data;
@synthesize code = _code;
+ (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.data = [PushRecordData modelObjectWithDictionary:[dict objectForKey:kPushRecordDataModelData]];
self.code = [[self objectOrNilForKey:kPushRecordDataModelCode fromDictionary:dict] intValue];
}
return self;
}
- (NSDictionary *)dictionaryRepresentation {
NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
[mutableDict setValue:[self.data dictionaryRepresentation] forKey:kPushRecordDataModelData];
[mutableDict setValue:[NSNumber numberWithInteger:self.code] forKey:kPushRecordDataModelCode];
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];
return [object isEqual:[NSNull null]] ? nil : object;
}
#pragma mark - NSCoding Methods
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super init];
self.data = [aDecoder decodeObjectForKey:kPushRecordDataModelData];
self.code = [aDecoder decodeIntegerForKey:kPushRecordDataModelCode];
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:_data forKey:kPushRecordDataModelData];
[aCoder encodeInteger:_code forKey:kPushRecordDataModelCode];
}
- (id)copyWithZone:(NSZone *)zone {
PushRecordDataModel *copy = [[PushRecordDataModel alloc] init];
if (copy) {
copy.data = [self.data copyWithZone:zone];
copy.code = self.code;
}
return copy;
}
@end