// // MOTasksBiGo.m // // Created by SuperCabbage on 2024/6/2 // Copyright (c) 2024 __MyCompanyName__. All rights reserved. // #import "MOTasksBiGo.h" NSString *const kMOTasksBiGoStatus = @"status"; NSString *const kMOTasksBiGoId = @"id"; NSString *const kMOTasksBiGoMinute = @"minute"; NSString *const kMOTasksBiGoRubine = @"rubine"; @interface MOTasksBiGo () - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict; @end @implementation MOTasksBiGo @synthesize status = _status; @synthesize id = _id; @synthesize minute = _minute; @synthesize rubine = _rubine; + (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.status = [[self objectOrNilForKey:kMOTasksBiGoStatus fromDictionary:dict] doubleValue]; self.id = [self objectOrNilForKey:kMOTasksBiGoId fromDictionary:dict]; self.minute = [[self objectOrNilForKey:kMOTasksBiGoMinute fromDictionary:dict] doubleValue]; self.rubine = [[self objectOrNilForKey:kMOTasksBiGoRubine fromDictionary:dict] doubleValue]; } return self; } - (NSDictionary *)dictionaryRepresentation { NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary]; [mutableDict setValue:[NSNumber numberWithDouble:self.status] forKey:kMOTasksBiGoStatus]; [mutableDict setValue:self.id forKey:kMOTasksBiGoId]; [mutableDict setValue:[NSNumber numberWithDouble:self.minute] forKey:kMOTasksBiGoMinute]; [mutableDict setValue:[NSNumber numberWithDouble:self.rubine] forKey:kMOTasksBiGoRubine]; 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.status = [aDecoder decodeDoubleForKey:kMOTasksBiGoStatus]; self.id = [aDecoder decodeObjectForKey:kMOTasksBiGoId]; self.minute = [aDecoder decodeDoubleForKey:kMOTasksBiGoMinute]; self.rubine = [aDecoder decodeDoubleForKey:kMOTasksBiGoRubine]; return self; } - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeDouble:_status forKey:kMOTasksBiGoStatus]; [aCoder encodeObject:_id forKey:kMOTasksBiGoId]; [aCoder encodeDouble:_minute forKey:kMOTasksBiGoMinute]; [aCoder encodeDouble:_rubine forKey:kMOTasksBiGoRubine]; } - (id)copyWithZone:(NSZone *)zone { MOTasksBiGo *copy = [[MOTasksBiGo alloc] init]; if (copy) { copy.status = self.status; copy.id = [self.id copyWithZone:zone]; copy.minute = self.minute; copy.rubine = self.rubine; } return copy; } @end