You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.9 KiB

//
// baseModel.m
// babyTravel
//
// Created by xTT on 2016/9/29.
// Copyright © 2016xTT. 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