| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- //
- // MOBaseInterrupt.m
- //
- // Created by SuperCabbage on 2025/1/10
- // Copyright (c) 2025 __MyCompanyName__. All rights reserved.
- //
- #import "MOBaseInterrupt.h"
- NSString *const kMOBaseInterruptVip = @"vip";
- NSString *const kMOBaseInterruptMedal = @"medal";
- NSString *const kMOBaseInterruptLevel = @"level";
- NSString *const kMOBaseInterruptGift = @"gift";
- NSString *const kMOBaseInterruptProp = @"prop";
- @interface MOBaseInterrupt ()
- - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
- @end
- @implementation MOBaseInterrupt
- @synthesize vip = _vip;
- @synthesize medal = _medal;
- @synthesize level = _level;
- @synthesize gift = _gift;
- @synthesize prop = _prop;
- + (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.vip = [[self objectOrNilForKey:kMOBaseInterruptVip fromDictionary:dict] boolValue];
- self.medal = [[self objectOrNilForKey:kMOBaseInterruptMedal fromDictionary:dict] boolValue];
- self.level = [[self objectOrNilForKey:kMOBaseInterruptLevel fromDictionary:dict] boolValue];
- self.gift = [[self objectOrNilForKey:kMOBaseInterruptGift fromDictionary:dict] boolValue];
- self.prop = [[self objectOrNilForKey:kMOBaseInterruptProp fromDictionary:dict] boolValue];
- }
-
- return self;
-
- }
- - (NSDictionary *)dictionaryRepresentation {
- NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
- [mutableDict setValue:[NSNumber numberWithBool:self.vip] forKey:kMOBaseInterruptVip];
- [mutableDict setValue:[NSNumber numberWithBool:self.medal] forKey:kMOBaseInterruptMedal];
- [mutableDict setValue:[NSNumber numberWithBool:self.level] forKey:kMOBaseInterruptLevel];
- [mutableDict setValue:[NSNumber numberWithBool:self.gift] forKey:kMOBaseInterruptGift];
- [mutableDict setValue:[NSNumber numberWithBool:self.prop] forKey:kMOBaseInterruptProp];
- 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.vip = [aDecoder decodeBoolForKey:kMOBaseInterruptVip];
- self.medal = [aDecoder decodeBoolForKey:kMOBaseInterruptMedal];
- self.level = [aDecoder decodeBoolForKey:kMOBaseInterruptLevel];
- self.gift = [aDecoder decodeBoolForKey:kMOBaseInterruptGift];
- self.prop = [aDecoder decodeBoolForKey:kMOBaseInterruptProp];
- return self;
- }
- - (void)encodeWithCoder:(NSCoder *)aCoder
- {
- [aCoder encodeBool:_vip forKey:kMOBaseInterruptVip];
- [aCoder encodeBool:_medal forKey:kMOBaseInterruptMedal];
- [aCoder encodeBool:_level forKey:kMOBaseInterruptLevel];
- [aCoder encodeBool:_gift forKey:kMOBaseInterruptGift];
- [aCoder encodeBool:_prop forKey:kMOBaseInterruptProp];
- }
- - (id)copyWithZone:(NSZone *)zone {
- MOBaseInterrupt *copy = [[MOBaseInterrupt alloc] init];
-
-
-
- if (copy) {
- copy.vip = self.vip;
- copy.medal = self.medal;
- copy.level = self.level;
- copy.gift = self.gift;
- copy.prop = self.prop;
- }
-
- return copy;
- }
- @end
|