// // baseModel.m // babyTravel // // Created by xTT on 2016/9/29. // Copyright © 2016年 xTT. All rights reserved. // #import "baseModel.h" #import "CJFileUtility.h" @implementation baseModel - (void)setDefaultValue{} + (void)getObjsSuccess:(void (^)(NSMutableArray *arr))success failure:(void (^)(NSError *error))failure{} + (void)getObjsWithID:(NSString *)ID success:(void (^)(NSMutableArray *arr))success failure:(void (^)(NSError *error))failure{} - (void)saveSuccess:(void (^)())success failure:(void (^)())failure{} - (void)deleteSuccess:(void (^)())success failure:(void (^)())failure{} - (void)setAvator:(NSString *)avator{ if (![_avator isEqualToString:avator]) { _avator = avator; WEAKSELF dispatch_async(dispatch_get_global_queue(0, 0), ^{ NSString *path = [CJFileUtility documentsPathSubDir:NSStringFromClass([self class]) andFile:[NSString stringWithFormat:@"%@",avator]]; NSData *data = [NSData dataWithContentsOfFile:path]; if (data.length > 0) { weakSelf.image = [UIImage imageWithData:data]; } if (!data){ data = [NSData dataWithContentsOfURL:[NSURL URLWithString:avator]]; if (data && data.length > 0) { weakSelf.image = [UIImage imageWithData:data]; dispatch_async(dispatch_get_main_queue(), ^(void) { if (weakSelf.block) { weakSelf.block(); } // [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadCircleDataView" object:nil]; }); [CJFileUtility writeToFile:path data:data]; } } }); } } @end