EModel.m 19 KB

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