MOTasksBiGo.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // MOTasksBiGo.m
  3. //
  4. // Created by SuperCabbage on 2024/6/2
  5. // Copyright (c) 2024 __MyCompanyName__. All rights reserved.
  6. //
  7. #import "MOTasksBiGo.h"
  8. NSString *const kMOTasksBiGoStatus = @"status";
  9. NSString *const kMOTasksBiGoId = @"id";
  10. NSString *const kMOTasksBiGoMinute = @"minute";
  11. NSString *const kMOTasksBiGoRubine = @"rubine";
  12. @interface MOTasksBiGo ()
  13. - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
  14. @end
  15. @implementation MOTasksBiGo
  16. @synthesize status = _status;
  17. @synthesize id = _id;
  18. @synthesize minute = _minute;
  19. @synthesize rubine = _rubine;
  20. + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict {
  21. return [[self alloc] initWithDictionary:dict];
  22. }
  23. - (instancetype)initWithDictionary:(NSDictionary *)dict {
  24. self = [super init];
  25. // This check serves to make sure that a non-NSDictionary object
  26. // passed into the model class doesn't break the parsing.
  27. if (self && [dict isKindOfClass:[NSDictionary class]]) {
  28. self.status = [[self objectOrNilForKey:kMOTasksBiGoStatus fromDictionary:dict] doubleValue];
  29. self.id = [self objectOrNilForKey:kMOTasksBiGoId fromDictionary:dict];
  30. self.minute = [[self objectOrNilForKey:kMOTasksBiGoMinute fromDictionary:dict] doubleValue];
  31. self.rubine = [[self objectOrNilForKey:kMOTasksBiGoRubine fromDictionary:dict] doubleValue];
  32. }
  33. return self;
  34. }
  35. - (NSDictionary *)dictionaryRepresentation {
  36. NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
  37. [mutableDict setValue:[NSNumber numberWithDouble:self.status] forKey:kMOTasksBiGoStatus];
  38. [mutableDict setValue:self.id forKey:kMOTasksBiGoId];
  39. [mutableDict setValue:[NSNumber numberWithDouble:self.minute] forKey:kMOTasksBiGoMinute];
  40. [mutableDict setValue:[NSNumber numberWithDouble:self.rubine] forKey:kMOTasksBiGoRubine];
  41. return [NSDictionary dictionaryWithDictionary:mutableDict];
  42. }
  43. - (NSString *)description {
  44. return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
  45. }
  46. #pragma mark - Helper Method
  47. - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
  48. id object = [dict objectForKey:aKey];
  49. return [object isEqual:[NSNull null]] ? nil : object;
  50. }
  51. #pragma mark - NSCoding Methods
  52. - (id)initWithCoder:(NSCoder *)aDecoder {
  53. self = [super init];
  54. self.status = [aDecoder decodeDoubleForKey:kMOTasksBiGoStatus];
  55. self.id = [aDecoder decodeObjectForKey:kMOTasksBiGoId];
  56. self.minute = [aDecoder decodeDoubleForKey:kMOTasksBiGoMinute];
  57. self.rubine = [aDecoder decodeDoubleForKey:kMOTasksBiGoRubine];
  58. return self;
  59. }
  60. - (void)encodeWithCoder:(NSCoder *)aCoder
  61. {
  62. [aCoder encodeDouble:_status forKey:kMOTasksBiGoStatus];
  63. [aCoder encodeObject:_id forKey:kMOTasksBiGoId];
  64. [aCoder encodeDouble:_minute forKey:kMOTasksBiGoMinute];
  65. [aCoder encodeDouble:_rubine forKey:kMOTasksBiGoRubine];
  66. }
  67. - (id)copyWithZone:(NSZone *)zone {
  68. MOTasksBiGo *copy = [[MOTasksBiGo alloc] init];
  69. if (copy) {
  70. copy.status = self.status;
  71. copy.id = [self.id copyWithZone:zone];
  72. copy.minute = self.minute;
  73. copy.rubine = self.rubine;
  74. }
  75. return copy;
  76. }
  77. @end