Model 提供了一个轻量级的 model 基类;支持多种数据格式;具有良好的 model 嵌套支持;
WWDatabase 提供了数据库连接与 sql 执行的公共入口;
modelAssociateDB model 对象使用 sqlite 持久化的操作;
使用示例
pod 'WWModel'
testModel 继承自 model;
NSDictionary * test = @{@"name":@"waiwai",@"age":@22,@"livePlace":@"中国南京",@"sex":@1};
testModel * model1 = [[testModel alloc]init];
[model1 setValuesForKeysWithDictionary:test];
[model1 display];
输出: 2015-09-29 17:05:09.573 WWModelMaster[3721:172393] 赋值:testModel-->出现多余数据 key:sex value:1
2015-09-29 17:05:09.574 WWModelMaster[3721:172393] testModel
name-->waiwai age-->22 livePlace-->中国南京
拥有完善的异常 key 检测机制
实现了 model 对象的 NSCopying,NSMutableCopying;
提供多种转换方式;初始化方式;
/**
/**
/**
/**
-(NSDictionary *) toDictionaryWithKeys:(NSArray *)propertyNames;
/**
-(NSData *) toDataWithKeys:(NSArray *)propertyNames;
/**
-(NSString *) toJsonStringWithKeys:(NSArray *)propertyNames;
同样具有完善的异常处理机制;
dictionarys 和 models 互相转换
NSDictionary * test = @{@"name":@"waiwai",@"age":@22,@"livePlace":@"中国南京"};
NSDictionary * test1 = @{@"name":@"huihui",@"age":@20,@"livePlace":@"中国南京"};
NSArray * models = [testModel modelsWithDictionarys:@[test,test1]];
NSDictionary * dicts = [testModel dictionarysWithModels:models convertKeys:@[@"name"]];
提供了 WWDatabase,提供了数据库连接与 sql 执行的公共入口;
独立模块,可以单独使用 WWDatabase 来实现自己的更多需求数据库功能;
这里提供了 model 连接 WWDatabase 使用 sqlite 实现数据持久化的方案;
(BOOL)saveModel:(id) model;
(BOOL)deleteModel:(id) model;
(BOOL)updateModel:(id) newModel;
(NSArray *)selectAll:(NSString *) tableName;
提供基本的增加、删除、更新、查询函数;
(BOOL)deleteWithModelTable:(NSString *)tableName where:(NSDictionary *)where;
(BOOL)updateWithModelTable:(NSString *)tableName Content:(NSDictionary *)updateContent where:(NSDictionary *)where;
(NSArray *)selectWithModelTable:(NSString *)tableName where:(NSDictionary *)where groupBy:(NSString *)group;
(id)findWithModelTable:(NSString *)tableName withPrimary:(NSUInteger)primary;
提供了复杂的增加、删除、更新、查询函数。
提供了使用示例;一个简单的通讯录应用。