| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- //
- // MOGuildBase.m
- //
- // Created by SuperCabbage on 2023/10/25
- // Copyright (c) 2023 __MyCompanyName__. All rights reserved.
- //
- #import "MOGuildBase.h"
- NSString *const kMOGuildBaseAnchor = @"anchor";
- NSString *const kMOGuildBaseId = @"id";
- NSString *const kMOGuildBaseCountry = @"country";
- NSString *const kMOGuildBaseName = @"name";
- NSString *const kMOGuildBaseLogo = @"logo";
- NSString *const kMOGuildBaseNo = @"no";
- @interface MOGuildBase ()
- - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
- @end
- @implementation MOGuildBase
- @synthesize anchor = _anchor;
- @synthesize id = _id;
- @synthesize country = _country;
- @synthesize name = _name;
- @synthesize logo = _logo;
- @synthesize no = _no;
- + (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.anchor = [[self objectOrNilForKey:kMOGuildBaseAnchor fromDictionary:dict] doubleValue];
- self.id = [self objectOrNilForKey:kMOGuildBaseId fromDictionary:dict];
- self.country = [self objectOrNilForKey:kMOGuildBaseCountry fromDictionary:dict];
- self.name = [self objectOrNilForKey:kMOGuildBaseName fromDictionary:dict];
- self.logo = [self objectOrNilForKey:kMOGuildBaseLogo fromDictionary:dict];
-
- self.no = [self objectOrNilForKey:kMOGuildBaseNo fromDictionary:dict];
- }
-
- return self;
-
- }
- - (NSDictionary *)dictionaryRepresentation {
- NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
- [mutableDict setValue:[NSNumber numberWithDouble:self.anchor] forKey:kMOGuildBaseAnchor];
- [mutableDict setValue:self.id forKey:kMOGuildBaseId];
- [mutableDict setValue:self.country forKey:kMOGuildBaseCountry];
- [mutableDict setValue:self.name forKey:kMOGuildBaseName];
- [mutableDict setValue:self.logo forKey:kMOGuildBaseLogo];
-
- [mutableDict setValue:self.no forKey:kMOGuildBaseNo];
- 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.anchor = [aDecoder decodeDoubleForKey:kMOGuildBaseAnchor];
- self.id = [aDecoder decodeObjectForKey:kMOGuildBaseId];
- self.country = [aDecoder decodeObjectForKey:kMOGuildBaseCountry];
- self.name = [aDecoder decodeObjectForKey:kMOGuildBaseName];
- self.logo = [aDecoder decodeObjectForKey:kMOGuildBaseLogo];
-
- self.no = [aDecoder decodeObjectForKey:kMOGuildBaseNo];
- return self;
- }
- - (void)encodeWithCoder:(NSCoder *)aCoder
- {
- [aCoder encodeDouble:_anchor forKey:kMOGuildBaseAnchor];
- [aCoder encodeObject:_id forKey:kMOGuildBaseId];
- [aCoder encodeObject:_country forKey:kMOGuildBaseCountry];
- [aCoder encodeObject:_name forKey:kMOGuildBaseName];
- [aCoder encodeObject:_logo forKey:kMOGuildBaseLogo];
-
- [aCoder encodeObject:_no forKey:kMOGuildBaseNo];
- }
- - (id)copyWithZone:(NSZone *)zone {
- MOGuildBase *copy = [[MOGuildBase alloc] init];
-
-
-
- if (copy) {
- copy.anchor = self.anchor;
- copy.id = [self.id copyWithZone:zone];
- copy.country = [self.country copyWithZone:zone];
- copy.name = [self.name copyWithZone:zone];
- copy.logo = [self.logo copyWithZone:zone];
-
- copy.no = [self.no copyWithZone:zone];
- }
-
- return copy;
- }
- @end
|