EModel.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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. self.videoType = [UserDataHelper getLoginType] == 0 ? VIDEO_TYPE_AGORA : VIDEO_TYPE_JUPHOON;
  242. }
  243. return self;
  244. }
  245. - (BOOL)isBind {
  246. return self.did != -1;
  247. }
  248. @end
  249. @implementation ChildModel
  250. - (instancetype)init {
  251. self = [super init];
  252. if (self) {
  253. self.device = [[DeviceModel alloc] init];
  254. self.lastLocation = [[BaseCoordinatesModel alloc] init];
  255. self.weather = [[BaseWeatherModel alloc] init];
  256. self.role = 0;
  257. self.areaCode = [EUtil getCountryCode];
  258. }
  259. return self;
  260. }
  261. - (BOOL)isChildSelected:(NSString*)cid {
  262. return [self.cid isEqualToString:cid];
  263. }
  264. @end
  265. @implementation ContactModel
  266. - (instancetype)init {
  267. self = [super init];
  268. if (self) {
  269. self.role = 2; //家人
  270. self.avatarLocal = 0;
  271. self.areaCode = [EUtil getCountryCode];
  272. }
  273. return self;
  274. }
  275. @end
  276. @implementation ContactListModel
  277. + (NSDictionary *)mj_objectClassInArray {
  278. return @{
  279. @"persons" : [ContactModel class],
  280. };//前边,是属性数组的名字,后边就是类名
  281. }
  282. - (NSMutableArray*)getFamilys {
  283. NSMutableArray* contacts = [[NSMutableArray alloc] init];
  284. for (ContactModel* model in self.persons) {
  285. if (model.role <= 2) {
  286. [contacts addObject:model];
  287. }
  288. }
  289. return contacts;
  290. }
  291. - (NSMutableArray*)getFriends {
  292. NSMutableArray* contacts = [[NSMutableArray alloc] init];
  293. for (ContactModel* model in self.persons) {
  294. if (model.role > 2) {
  295. [contacts addObject:model];
  296. }
  297. }
  298. return contacts;
  299. }
  300. @end
  301. @implementation FenceModel
  302. - (instancetype)init {
  303. self = [super init];
  304. if (self) {
  305. self.range = 100;
  306. self.state = 1;
  307. self.category = FENCE_CATEGORY_CUSTOM;
  308. self.coordinateType = 1;
  309. }
  310. return self;
  311. }
  312. @end
  313. @implementation FenceListModel
  314. - (instancetype)init {
  315. self = [super init];
  316. if (self) {
  317. self.fences = @[];
  318. }
  319. return self;
  320. }
  321. + (NSDictionary *)mj_objectClassInArray {
  322. return @{
  323. @"fences" : [FenceModel class],
  324. };//前边,是属性数组的名字,后边就是类名
  325. }
  326. @end
  327. @implementation HistoryPathModel
  328. @end
  329. @implementation StrangerInterceptModel
  330. @end
  331. @implementation SchoolTimeModel
  332. - (instancetype)init {
  333. self = [super init];
  334. if (self) {
  335. NSInteger hour = [EUtil getHour];
  336. self.startTime = hour >= 10 ? [NSString stringWithFormat:@"%ld:00", (long)hour] : [NSString stringWithFormat:@"0%ld:00", (long)hour];
  337. 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];
  338. self.repeats = @"1111100";
  339. self.status = 1;
  340. self.holidaysFlag = 1;
  341. }
  342. return self;
  343. }
  344. + (NSDictionary *)mj_replacedKeyFromPropertyName {
  345. //模型和字典的字段不对应需要转化
  346. return @{};
  347. }
  348. @end
  349. @implementation AlarmClockModel
  350. - (instancetype)init {
  351. self = [super init];
  352. if (self) {
  353. self.label = @"0";
  354. self.time = [NSString stringWithFormat:@"%@:%@", [EUtil getHourString], [EUtil getMinuteString]];
  355. self.repeats = @"0000000";
  356. self.status = 1;
  357. self.holidaysFlag = 1;
  358. }
  359. return self;
  360. }
  361. @end
  362. @implementation ApnModel
  363. @end
  364. @implementation CallRecordModel
  365. @end
  366. @implementation PushMessageParamsModel
  367. - (instancetype)init {
  368. self = [super init];
  369. if (self) {
  370. }
  371. return self;
  372. }
  373. @end
  374. @implementation PushMessageModel
  375. - (instancetype)init {
  376. self = [super init];
  377. if (self) {
  378. self.childModel = [[ChildModel alloc] init];
  379. }
  380. return self;
  381. }
  382. - (NSString*)getMessage {
  383. switch (self.type) {
  384. case 10:
  385. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.10", nil), self.params.name, self.params.num];
  386. case 20: {
  387. NSDate* date = [NSDate dateWithTimeIntervalSince1970:self.create_time/1000];
  388. //NSDate* date = [NSDate getDateFromString:@"HH:mm" timeString:self.params.time];
  389. NSString* time = [date getTimeString];
  390. if (self.params.fenceType == 1) {
  391. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.20.1", nil), self.params.name, time, self.params.fenceName];
  392. } else {
  393. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.20.2", nil), self.params.name, time, self.params.fenceName];
  394. }
  395. }
  396. case 30:
  397. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.30", nil), self.params.name, self.params.friendName];
  398. case 40:
  399. if (self.params.status <= 1) {
  400. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.40.0", nil), self.params.name];
  401. } else {
  402. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.40.1", nil), self.params.name];
  403. }
  404. case 50:
  405. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.50", nil), self.params.name];
  406. case 60:
  407. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.60", nil), self.params.name];
  408. case 70:
  409. return [NSString stringWithFormat:NSLocalizedString(@"PAM.Type.Content.70", nil), self.params.name];
  410. default:
  411. break;
  412. }
  413. return NSLocalizedString(@"PAM.Type.Content.1000", nil);
  414. }
  415. @end
  416. @implementation RealPositionModel
  417. @end
  418. @implementation SessionMemberModel
  419. + (NSDictionary *)mj_replacedKeyFromPropertyName {
  420. //模型和字典的字段不对应需要转化
  421. return @{
  422. @"role":@"refRole",
  423. };
  424. }
  425. @end
  426. @implementation SessionMessagePayloadModel
  427. @end
  428. @implementation SessionMessageModel
  429. - (instancetype)init {
  430. self = [super init];
  431. if (self) {
  432. self.msgId = 0;
  433. }
  434. return self;
  435. }
  436. @end
  437. @implementation SocketPingPongModel
  438. @end
  439. @implementation SocketVideoModel
  440. @end
  441. @implementation SessionModel
  442. + (NSDictionary *)mj_objectClassInArray {
  443. return @{
  444. @"members" : [SessionMemberModel class],
  445. };//前边,是属性数组的名字,后边就是类名
  446. }
  447. - (NSInteger)getSessionType {
  448. return self.isGroup ? 0 : 1;
  449. }
  450. - (NSString*)getChildId {
  451. SessionMemberModel* model = [self getChildMember];
  452. if (model) {
  453. return model.refId;
  454. } else {
  455. return @"";
  456. }
  457. }
  458. - (SessionMemberModel*)getChildMember {
  459. for (SessionMemberModel* model in self.members) {
  460. if ([model.refId isEqualToString:self.cid]) {
  461. return model;
  462. }
  463. }
  464. return nil;
  465. }
  466. - (NSArray<SessionMemberModel*>*)getMembers {
  467. NSMutableArray* array = [[NSMutableArray alloc] init];
  468. for (SessionMemberModel* model in self.members) {
  469. [array addObject:model];
  470. }
  471. return array;
  472. }
  473. - (NSArray*)getMembersAvatars {
  474. NSMutableArray* array = [[NSMutableArray alloc] init];
  475. NSArray* members = [self getMembers];
  476. for (SessionMemberModel* model in members) {
  477. [array addObject:model.avatarHttp];
  478. }
  479. return array;
  480. }
  481. @end
  482. @implementation SocketModel
  483. @end
  484. @implementation SocketChatModel
  485. @end
  486. @implementation SocketCoordinatesModel
  487. @end
  488. @implementation ScheduleEventData
  489. static NSString *schedule_id_key = @"schedule_Id_key";
  490. static NSString *schedule_time_id_key = @"Time_ID_key";
  491. static NSString *schedule_child_id_key = @"Child_ID_key";
  492. static NSString *schedule_date_key = @"Date_key";
  493. static NSString *schedule_week_set = @"WeekDic_key";
  494. static NSString *schedule_name_key = @"Schedule_Name";
  495. static NSString *schedule_type_key = @"Schedule_Type_key";
  496. static NSString *schedule_advance_key = @"Schedule_Advance_Day_Key";
  497. static NSString *schedule_color_index_key = @"Schedule_Color_Index_Key";
  498. - (instancetype)initWithDict:(NSDictionary *)dict
  499. {
  500. if (self = [super init]) {
  501. self.mID = [dict[@"Id"] replaceNil];
  502. self.mTimeID = [dict[@"OperationTime"] intValue];
  503. NSString *dateStr = [dict[@"RemindDate"] replaceNil];
  504. NSString *timeStr = [NSString stringWithFormat:@"%@ %@", dateStr, [dict[@"RemindTime"] replaceNil]];
  505. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  506. [dateFormatter setDateFormat:@"yyyyMMdd HH:mm"];
  507. self.time = [dateFormatter dateFromString:timeStr];
  508. self.mOperationType = [dict[@"OperationType"] intValue];
  509. self.mChildId = [NSString stringWithFormat:@"%d", [dict[@"cid"] intValue]];
  510. NSString *weekday = dict[@"WeekDay"];
  511. //weekday = @"{\"1\":\"1\", \"2\":\"1\", \"3\":\"1\", \"4\":\"1\",\"5\":\"1\",\"6\":\"0\",\"7\":\"0\"}";
  512. NSData *data = [weekday dataUsingEncoding:NSUTF8StringEncoding];
  513. NSError *error;
  514. NSDictionary *weekDic = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
  515. self.weekSetDic = [[NSMutableDictionary alloc] initWithDictionary:weekDic];
  516. self.mScheduleName = dict[@"RemindContent"];
  517. self.mType = (EScheduleType)[dict[@"Type"] intValue];
  518. self.advanceDay = [dict[@"AdvanceDay"] intValue];
  519. self.colorIndex = [dict[@"Colour"] intValue];
  520. }
  521. return self;
  522. }
  523. - (id) initWithCoder: (NSCoder *)coder
  524. {
  525. if (self = [super init])
  526. {
  527. self.mID = [coder decodeObjectForKey:schedule_id_key];
  528. self.mTimeID = [[coder decodeObjectForKey:schedule_time_id_key] longValue];
  529. self.mChildId = [coder decodeObjectForKey:schedule_child_id_key];
  530. self.time = [coder decodeObjectForKey:schedule_date_key];
  531. NSDictionary *weekDic = [coder decodeObjectForKey:schedule_week_set];
  532. self.weekSetDic = [[NSMutableDictionary alloc] initWithDictionary:weekDic];
  533. self.mScheduleName = [coder decodeObjectForKey:schedule_name_key];
  534. self.mType = (EScheduleType)[[coder decodeObjectForKey:schedule_type_key] intValue];
  535. self.advanceDay = [[coder decodeObjectForKey:schedule_advance_key] intValue];
  536. self.colorIndex = [[coder decodeObjectForKey:schedule_color_index_key] intValue];
  537. }
  538. return self;
  539. }
  540. - (void)encodeWithCoder: (NSCoder *)coder
  541. {
  542. [coder encodeObject:self.mID forKey:schedule_id_key];
  543. [coder encodeObject:[NSNumber numberWithLong:self.mTimeID] forKey:schedule_time_id_key];
  544. [coder encodeObject:self.mChildId forKey:schedule_child_id_key];
  545. [coder encodeObject:self.time forKey:schedule_date_key];
  546. [coder encodeObject:self.weekSetDic forKey:schedule_week_set];
  547. [coder encodeObject:self.mScheduleName forKey:schedule_name_key];
  548. [coder encodeObject:[NSNumber numberWithInt:self.mType] forKey:schedule_type_key];
  549. [coder encodeObject:[NSNumber numberWithInt:self.advanceDay] forKey:schedule_advance_key];
  550. [coder encodeObject:[NSNumber numberWithInt:self.colorIndex] forKey:schedule_color_index_key];
  551. }
  552. - (BOOL)isRepeatedEvent
  553. {
  554. BOOL hasRepeated = NO;
  555. for (id akey in [self.weekSetDic allKeys]) {
  556. NSString *valueStr = (NSString *)[self.weekSetDic objectForKey:akey];
  557. if([valueStr isEqualToString:@"1"])
  558. {
  559. hasRepeated = YES;
  560. break;
  561. }
  562. }
  563. return hasRepeated;
  564. }
  565. @end