EModel.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. //
  2. // Artimenring
  3. //
  4. // Created by BaH Cy on 14/12/19.
  5. // Copyright (c) 2014年 BaH Cy. All rights reserved.
  6. //
  7. #import "EModel.h"
  8. #import <objc/message.h>
  9. @implementation BaseModel
  10. - (nonnull id)copyWithZone:(NSZone *)zone{
  11. id objCopy = [[[self class] allocWithZone:zone] init];
  12. unsigned int count = 0;
  13. objc_property_t *properties = class_copyPropertyList([self class], &count);
  14. for (int i = 0; i < count; i++) {
  15. objc_property_t property = properties[i];
  16. const char *name = property_getName(property);
  17. NSString *propertyName = [NSString stringWithUTF8String:name];
  18. id value = [self valueForKey:propertyName];
  19. if (value && ([value isKindOfClass:[NSMutableArray class]] || [value isKindOfClass:[NSArray class]])) {
  20. id valueCopy = [[NSArray alloc] initWithArray:value copyItems:YES];
  21. [objCopy setValue:valueCopy forKey:propertyName];
  22. } else if (value) {
  23. [objCopy setValue:[value copy] forKey:propertyName];
  24. }
  25. }
  26. free(properties);
  27. return objCopy;
  28. }
  29. - (nonnull id)mutableCopyWithZone:(NSZone *)zone{
  30. id objCopy = [[[self class] allocWithZone:zone] init];
  31. unsigned int count = 0;
  32. objc_property_t *properties = class_copyPropertyList([self class], &count);
  33. for (int i = 0; i < count; i++) {
  34. objc_property_t property = properties[i];
  35. const char *name = property_getName(property);
  36. NSString *propertyName = [NSString stringWithUTF8String:name];
  37. id value = [self valueForKey:propertyName];
  38. if (value && ([value isKindOfClass:[NSMutableArray class]] || [value isKindOfClass:[NSArray class]])) {
  39. id valueCopy = [[NSMutableArray alloc] initWithArray:value copyItems:YES];
  40. [objCopy setValue:valueCopy forKey:propertyName];
  41. } else if(value) {
  42. [objCopy setValue:[value copy] forKey:propertyName];
  43. }
  44. }
  45. free(properties);
  46. unsigned int countSupper = 0;
  47. objc_property_t *propertiesSupper = class_copyPropertyList([self superclass], &countSupper);
  48. for (int i = 0; i < countSupper; i++) {
  49. objc_property_t property = propertiesSupper[i];
  50. const char *name = property_getName(property);
  51. NSString *propertyName = [NSString stringWithUTF8String:name];
  52. id value = [self valueForKey:propertyName];
  53. if (value && ([value isKindOfClass:[NSMutableArray class]] || [value isKindOfClass:[NSArray class]])) {
  54. id valueCopy = [[NSMutableArray alloc] initWithArray:value copyItems:YES];
  55. [objCopy setValue:valueCopy forKey:propertyName];
  56. } else if(value) {
  57. [objCopy setValue:[value copy] forKey:propertyName];
  58. }
  59. }
  60. free(propertiesSupper);
  61. return objCopy;
  62. }
  63. + (BOOL)isnull:(NSString*)value {
  64. return value == nil || value == (id)[NSNull null] || [value isEqualToString:@"<null>"] || [value isEqualToString:@""];
  65. }
  66. + (void)replaceObject:(NSMutableArray*)array oldObject:(id)oldObject newObject:(id)newObject {
  67. NSInteger index = [array indexOfObject:oldObject];
  68. [array replaceObjectAtIndex:index withObject:[newObject mutableCopy]];
  69. }
  70. @end
  71. @implementation BaseWeatherModel
  72. @end
  73. @implementation BaseCoordinatesModel
  74. - (instancetype)init {
  75. self = [super init];
  76. if (self) {
  77. self.weatherResult = [[BaseWeatherModel alloc] init];
  78. }
  79. return self;
  80. }
  81. - (BOOL)isCoordinatesValid {
  82. return [self.latitude doubleValue] != 0 || [self.longitude doubleValue] != 0;
  83. }
  84. - (CLLocationCoordinate2D)getCoordinates {
  85. return CLLocationCoordinate2DMake([self.latitude doubleValue], [self.longitude doubleValue]);
  86. }
  87. - (void)setCoordinates:(double)lat lng:(double)lng {
  88. self.latitude = [NSString stringWithFormat:@"%f", lat];
  89. self.longitude = [NSString stringWithFormat:@"%f", lng];
  90. }
  91. - (void)setCoordinates:(CLLocationCoordinate2D)coordinates {
  92. self.latitude = [NSString stringWithFormat:@"%f", coordinates.latitude];
  93. self.longitude = [NSString stringWithFormat:@"%f", coordinates.longitude];
  94. }
  95. @end
  96. @implementation BaseAvatarModel
  97. - (instancetype)init {
  98. self = [super init];
  99. if (self) {
  100. self.avatar = @"";
  101. self.avatarUrl = @"";
  102. self.avatarHttp = @"";
  103. }
  104. return self;
  105. }
  106. - (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property {
  107. if ([property.name isEqualToString:@"avatar"] || [property.name isEqualToString:@"avatarUrl"]) {
  108. if (!oldValue || oldValue == [NSNull null]) {
  109. return oldValue;
  110. }
  111. NSString* avatar = oldValue;
  112. if ([avatar.lowercaseString containsString:@"http"]) {
  113. self.avatarHttp = avatar;
  114. self.avatarLocal = 0;
  115. } else {
  116. avatar = [avatar stringByReplacingOccurrencesOfString:CONTACT_RELATION_LOCAL withString:@""];
  117. self.avatarHttp = @"";
  118. self.avatarLocal = [avatar intValue];
  119. }
  120. }
  121. return oldValue;
  122. }
  123. - (NSString *)getAvatarLocalName {
  124. if (self.avatarLocal >= 1 && self.avatarLocal <= RELATION_FAMILY_MAX)
  125. return [NSString stringWithFormat:@"contact_family_%ld", self.avatarLocal];
  126. else if (self.avatarLocal >= RELATION_FRIEND_MIN && self.avatarLocal <= RELATION_FRIEND_MAX)
  127. return [NSString stringWithFormat:@"contact_friend_%ld", self.avatarLocal];
  128. else
  129. return @"";
  130. }
  131. - (NSString*)joinServerAvatar {
  132. if (self.avatarHttp.length > 0)
  133. return self.avatarHttp;
  134. else if (self.avatarLocal > 0) {
  135. return [NSString stringWithFormat:@"%@%ld", CONTACT_RELATION_LOCAL, self.avatarLocal];
  136. } else
  137. return @"";
  138. }
  139. @end
  140. @implementation BaseRepeatsModel
  141. - (BOOL)getRepeatStatus:(NSInteger)index {
  142. NSString* s = [NSString stringWithFormat:@"%c", [self.repeats characterAtIndex:index]];
  143. return [s isEqualToString:@"1"];
  144. }
  145. - (void)setRepeatStatus:(NSInteger)index value:(NSString*)value {
  146. self.repeats = [self.repeats stringByReplacingCharactersInRange:NSMakeRange(index, 1) withString:value];
  147. }
  148. - (void)flipRepeatStatus:(NSInteger)index {
  149. //替换,翻转
  150. NSString* value = [self getRepeatStatus:index] ? @"0" : @"1";
  151. [self setRepeatStatus:index value:value];
  152. }
  153. - (NSInteger)getRepeatMode {
  154. //0:仅一次; 1:周一到周五; 2:每天; 3:自定义;
  155. if ([self.repeats isEqualToString:@"0000000"]) {
  156. return 0;
  157. } else if ([self.repeats isEqualToString:@"1111111"]) {
  158. return 2;
  159. } else if ([self.repeats isEqualToString:@"1111100"]) {
  160. return 1;
  161. } else {
  162. return 3;
  163. }
  164. }
  165. //是否至少选择一项
  166. - (BOOL)isSelectOne {
  167. BOOL isEquel = [self.repeats isEqualToString:@"0000000"];
  168. return !isEquel;
  169. }
  170. - (NSString*)getRepeatString {
  171. NSInteger mode = [self getRepeatMode];
  172. if (mode == 0) {
  173. return NSLocalizedString(@"STL.Weekday.Never", nil);
  174. } else if (mode == 2) {
  175. return NSLocalizedString(@"STL.Weekday.Everyday", nil);
  176. } else {
  177. //不是每天
  178. NSString * ret = @"";
  179. for (int i = 0; i < self.repeats.length; i++) {
  180. NSString* s = [NSString stringWithFormat:@"%c", [self.repeats characterAtIndex:i]];
  181. if ([s isEqualToString:@"0"])
  182. continue;
  183. NSString* key = [NSString stringWithFormat:@"%@.%d", @"STL.Weekday", i];
  184. ret = [NSString stringWithFormat:@"%@ %@ ", ret, NSLocalizedString(key, nil)];
  185. }
  186. return ret;
  187. }
  188. }
  189. @end
  190. @implementation CloudMatchModel
  191. - (instancetype)init {
  192. self = [super init];
  193. if (self) {
  194. self.videoCall = YES;
  195. self.chat = YES;
  196. self.chatMore = NO;
  197. self.chatEmoji = NO;
  198. self.chatImage = YES;
  199. self.chatVideo = YES;
  200. self.monitor = NO;
  201. self.shortNum = NO;
  202. self.callCharge = NO;
  203. self.callRecord = NO;
  204. self.watchSMS = NO;
  205. self.electricityMode = NO;
  206. self.flowControl = NO;
  207. self.flowQuery = NO;
  208. self.eyeCare = NO;
  209. self.wifi = NO;
  210. self.autoOnOff = NO;
  211. self.function = NO;
  212. self.strangerIntercept = YES;
  213. self.eventReminder = NO;
  214. self.magicAcademy = NO;
  215. self.redFlower = NO;
  216. self.update = NO;
  217. self.autoUpdate = YES;
  218. self.strongTrack = NO;
  219. self.autoLocation = NO;
  220. self.sendLocation = YES;
  221. self.moveType = NO;
  222. self.holiday = NO;
  223. self.clock = YES;
  224. self.clockOnce = NO;
  225. self.clockMax = 5;
  226. self.apn = YES;
  227. self.chatVoiceMax = 15;
  228. self.historyPathMax = 7;
  229. }
  230. return self;
  231. }
  232. @end
  233. @implementation LogInModel
  234. - (instancetype)init {
  235. self = [super init];
  236. if (self) {
  237. self.areaCode = [EUtil getCountryCode];
  238. }
  239. return self;
  240. }
  241. @end
  242. @implementation DeviceModel
  243. - (instancetype)init {
  244. self = [super init];
  245. if (self) {
  246. self.did = -1;
  247. self.match = [[CloudMatchModel alloc] init];
  248. self.videoType = VIDEO_TYPE_AGORA;
  249. }
  250. return self;
  251. }
  252. - (BOOL)isBind {
  253. return self.did != -1;
  254. }
  255. @end
  256. @implementation ChildModel
  257. - (instancetype)init {
  258. self = [super init];
  259. if (self) {
  260. self.device = [[DeviceModel alloc] init];
  261. self.lastLocation = [[BaseCoordinatesModel alloc] init];
  262. self.role = 0;
  263. self.areaCode = [EUtil getCountryCode];
  264. }
  265. return self;
  266. }
  267. - (BOOL)isChildSelected:(NSString*)cid {
  268. return [self.cid isEqualToString:cid];
  269. }
  270. @end
  271. @implementation ContactModel
  272. - (instancetype)init {
  273. self = [super init];
  274. if (self) {
  275. self.role = 2; //家人
  276. self.avatarLocal = 0;
  277. self.areaCode = [EUtil getCountryCode];
  278. }
  279. return self;
  280. }
  281. @end
  282. @implementation ContactListModel
  283. + (NSDictionary *)mj_objectClassInArray {
  284. return @{
  285. @"persons" : [ContactModel class],
  286. };//前边,是属性数组的名字,后边就是类名
  287. }
  288. - (NSMutableArray*)getFamilys {
  289. NSMutableArray* contacts = [[NSMutableArray alloc] init];
  290. for (ContactModel* model in self.persons) {
  291. if (model.role <= 2) {
  292. [contacts addObject:model];
  293. }
  294. }
  295. return contacts;
  296. }
  297. - (NSMutableArray*)getFriends {
  298. NSMutableArray* contacts = [[NSMutableArray alloc] init];
  299. for (ContactModel* model in self.persons) {
  300. if (model.role > 2) {
  301. [contacts addObject:model];
  302. }
  303. }
  304. return contacts;
  305. }
  306. @end
  307. @implementation FenceModel
  308. - (instancetype)init {
  309. self = [super init];
  310. if (self) {
  311. self.range = 100;
  312. self.state = 1;
  313. self.category = FENCE_CATEGORY_CUSTOM;
  314. self.coordinateType = 1;
  315. }
  316. return self;
  317. }
  318. @end
  319. @implementation FenceListModel
  320. - (instancetype)init {
  321. self = [super init];
  322. if (self) {
  323. self.fences = @[];
  324. }
  325. return self;
  326. }
  327. + (NSDictionary *)mj_objectClassInArray {
  328. return @{
  329. @"fences" : [FenceModel class],
  330. };//前边,是属性数组的名字,后边就是类名
  331. }
  332. @end
  333. @implementation HistoryPathModel
  334. @end
  335. @implementation StrangerInterceptModel
  336. @end
  337. @implementation SchoolTimeModel
  338. - (instancetype)init {
  339. self = [super init];
  340. if (self) {
  341. NSInteger hour = [EUtil getHour];
  342. self.startTime = hour >= 10 ? [NSString stringWithFormat:@"%ld:00", (long)hour] : [NSString stringWithFormat:@"0%ld:00", (long)hour];
  343. self.endTime = hour >= 9 ? [NSString stringWithFormat:@"%ld:00", ((long)hour + 1) < 24? ((long)hour + 1):(long)hour] : [NSString stringWithFormat:@"0%ld:00", ((long)hour + 1) < 24? ((long)hour + 1):(long)hour];
  344. self.repeats = @"1111100";
  345. self.status = 1;
  346. self.holidaysFlag = 1;
  347. }
  348. return self;
  349. }
  350. + (NSDictionary *)mj_replacedKeyFromPropertyName {
  351. //模型和字典的字段不对应需要转化
  352. return @{};
  353. }
  354. @end
  355. @implementation AlarmClockModel
  356. - (instancetype)init {
  357. self = [super init];
  358. if (self) {
  359. self.label = @"0";
  360. self.time = [NSString stringWithFormat:@"%@:%@", [EUtil getHourString], [EUtil getMinuteString]];
  361. self.repeats = @"0000000";
  362. self.status = 1;
  363. self.holidaysFlag = 1;
  364. }
  365. return self;
  366. }
  367. @end
  368. @implementation ApnModel
  369. @end
  370. @implementation CallRecordModel
  371. @end
  372. @implementation PushMessageParamsModel
  373. - (instancetype)init {
  374. self = [super init];
  375. if (self) {
  376. }
  377. return self;
  378. }
  379. @end
  380. @implementation PushMessageModel
  381. - (instancetype)init {
  382. self = [super init];
  383. if (self) {
  384. self.childModel = [[ChildModel alloc] init];
  385. }
  386. return self;
  387. }
  388. - (NSString*)getMessage {
  389. switch (self.type) {
  390. case 10:
  391. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.10", nil), self.params.name, self.params.num];
  392. case 20: {
  393. NSDate* date = [NSDate dateWithTimeIntervalSince1970:self.create_time/1000];
  394. //NSDate* date = [NSDate getDateFromString:@"HH:mm" timeString:self.params.time];
  395. NSString* time = [date getTimeString];
  396. if (self.params.fenceType == 1) {
  397. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.20.1", nil), self.params.name, time, self.params.fenceName];
  398. } else {
  399. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.20.2", nil), self.params.name, time, self.params.fenceName];
  400. }
  401. }
  402. case 30:
  403. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.30", nil), self.params.name, self.params.friendName];
  404. case 40:
  405. if (self.params.status <= 1) {
  406. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.40.0", nil), self.params.name];
  407. } else {
  408. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.40.1", nil), self.params.name];
  409. }
  410. case 50:
  411. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.50", nil), self.params.name];
  412. case 60:
  413. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.60", nil), self.params.name];
  414. case 70:
  415. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.70", nil), self.params.name];
  416. default:
  417. break;
  418. }
  419. return NSLocalizedString(@"PAM.Type.Content.1000", nil);
  420. }
  421. @end
  422. @implementation RealPositionModel
  423. @end
  424. @implementation SessionMemberModel
  425. + (NSDictionary *)mj_replacedKeyFromPropertyName {
  426. //模型和字典的字段不对应需要转化
  427. return @{
  428. @"role":@"refRole",
  429. };
  430. }
  431. @end
  432. @implementation SessionMessagePayloadModel
  433. @end
  434. @implementation SessionMessageModel
  435. - (instancetype)init {
  436. self = [super init];
  437. if (self) {
  438. self.msgId = 0;
  439. }
  440. return self;
  441. }
  442. @end
  443. @implementation SocketContentModel
  444. @end
  445. @implementation SessionModel
  446. + (NSDictionary *)mj_objectClassInArray {
  447. return @{
  448. @"members" : [SessionMemberModel class],
  449. };//前边,是属性数组的名字,后边就是类名
  450. }
  451. - (NSInteger)getSessionType {
  452. return self.isGroup ? 0 : 1;
  453. }
  454. - (NSString*)getChildId {
  455. SessionMemberModel* model = [self getChildMember];
  456. if (model) {
  457. return model.refId;
  458. } else {
  459. return @"";
  460. }
  461. }
  462. - (SessionMemberModel*)getChildMember {
  463. for (SessionMemberModel* model in self.members) {
  464. if ([model.refId isEqualToString:self.cid]) {
  465. return model;
  466. }
  467. }
  468. return nil;
  469. }
  470. - (NSArray<SessionMemberModel*>*)getMembers {
  471. NSMutableArray* array = [[NSMutableArray alloc] init];
  472. for (SessionMemberModel* model in self.members) {
  473. [array addObject:model];
  474. }
  475. return array;
  476. }
  477. - (NSArray*)getMembersAvatars {
  478. NSMutableArray* array = [[NSMutableArray alloc] init];
  479. NSArray* members = [self getMembers];
  480. for (SessionMemberModel* model in members) {
  481. [array addObject:model.avatarHttp];
  482. }
  483. return array;
  484. }
  485. @end
  486. @implementation SocketModel
  487. @end
  488. @implementation SocketChatModel
  489. @end
  490. @implementation SocketCoordinatesModel
  491. @end
  492. @implementation ScheduleEventData
  493. static NSString *schedule_id_key = @"schedule_Id_key";
  494. static NSString *schedule_time_id_key = @"Time_ID_key";
  495. static NSString *schedule_child_id_key = @"Child_ID_key";
  496. static NSString *schedule_date_key = @"Date_key";
  497. static NSString *schedule_week_set = @"WeekDic_key";
  498. static NSString *schedule_name_key = @"Schedule_Name";
  499. static NSString *schedule_type_key = @"Schedule_Type_key";
  500. static NSString *schedule_advance_key = @"Schedule_Advance_Day_Key";
  501. static NSString *schedule_color_index_key = @"Schedule_Color_Index_Key";
  502. - (instancetype)initWithDict:(NSDictionary *)dict
  503. {
  504. if (self = [super init]) {
  505. self.mID = [dict[@"Id"] replaceNil];
  506. self.mTimeID = [dict[@"OperationTime"] intValue];
  507. NSString *dateStr = [dict[@"RemindDate"] replaceNil];
  508. NSString *timeStr = [NSString stringWithFormat:@"%@ %@", dateStr, [dict[@"RemindTime"] replaceNil]];
  509. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  510. [dateFormatter setDateFormat:@"yyyyMMdd HH:mm"];
  511. self.time = [dateFormatter dateFromString:timeStr];
  512. self.mOperationType = [dict[@"OperationType"] intValue];
  513. self.mChildId = [NSString stringWithFormat:@"%d", [dict[@"cid"] intValue]];
  514. NSString *weekday = dict[@"WeekDay"];
  515. //weekday = @"{\"1\":\"1\", \"2\":\"1\", \"3\":\"1\", \"4\":\"1\",\"5\":\"1\",\"6\":\"0\",\"7\":\"0\"}";
  516. NSData *data = [weekday dataUsingEncoding:NSUTF8StringEncoding];
  517. NSError *error;
  518. NSDictionary *weekDic = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
  519. self.weekSetDic = [[NSMutableDictionary alloc] initWithDictionary:weekDic];
  520. self.mScheduleName = dict[@"RemindContent"];
  521. self.mType = (EScheduleType)[dict[@"Type"] intValue];
  522. self.advanceDay = [dict[@"AdvanceDay"] intValue];
  523. self.colorIndex = [dict[@"Colour"] intValue];
  524. }
  525. return self;
  526. }
  527. - (id) initWithCoder: (NSCoder *)coder
  528. {
  529. if (self = [super init])
  530. {
  531. self.mID = [coder decodeObjectForKey:schedule_id_key];
  532. self.mTimeID = [[coder decodeObjectForKey:schedule_time_id_key] longValue];
  533. self.mChildId = [coder decodeObjectForKey:schedule_child_id_key];
  534. self.time = [coder decodeObjectForKey:schedule_date_key];
  535. NSDictionary *weekDic = [coder decodeObjectForKey:schedule_week_set];
  536. self.weekSetDic = [[NSMutableDictionary alloc] initWithDictionary:weekDic];
  537. self.mScheduleName = [coder decodeObjectForKey:schedule_name_key];
  538. self.mType = (EScheduleType)[[coder decodeObjectForKey:schedule_type_key] intValue];
  539. self.advanceDay = [[coder decodeObjectForKey:schedule_advance_key] intValue];
  540. self.colorIndex = [[coder decodeObjectForKey:schedule_color_index_key] intValue];
  541. }
  542. return self;
  543. }
  544. - (void)encodeWithCoder: (NSCoder *)coder
  545. {
  546. [coder encodeObject:self.mID forKey:schedule_id_key];
  547. [coder encodeObject:[NSNumber numberWithLong:self.mTimeID] forKey:schedule_time_id_key];
  548. [coder encodeObject:self.mChildId forKey:schedule_child_id_key];
  549. [coder encodeObject:self.time forKey:schedule_date_key];
  550. [coder encodeObject:self.weekSetDic forKey:schedule_week_set];
  551. [coder encodeObject:self.mScheduleName forKey:schedule_name_key];
  552. [coder encodeObject:[NSNumber numberWithInt:self.mType] forKey:schedule_type_key];
  553. [coder encodeObject:[NSNumber numberWithInt:self.advanceDay] forKey:schedule_advance_key];
  554. [coder encodeObject:[NSNumber numberWithInt:self.colorIndex] forKey:schedule_color_index_key];
  555. }
  556. - (BOOL)isRepeatedEvent
  557. {
  558. BOOL hasRepeated = NO;
  559. for (id akey in [self.weekSetDic allKeys]) {
  560. NSString *valueStr = (NSString *)[self.weekSetDic objectForKey:akey];
  561. if([valueStr isEqualToString:@"1"])
  562. {
  563. hasRepeated = YES;
  564. break;
  565. }
  566. }
  567. return hasRepeated;
  568. }
  569. @end