Charlin出框架的目标:简单、易用、实用、高度封装、绝对解耦!
The purpose of Charlin’s frame: simple, ease of use, practical,
highly packaged and absolute decoupling.
MJExtension续作之一:取代Core Data的利器,实现ios一键ORM的基石!
One sequel for MJExtetnsion: a better tool to replace Core Data
and a cornerstone of achieving one key ORM for iOS.
第一季:CoreFMDB https://github.com/nsdictionary/CoreFMDB
第二季:CoreArchive https://github.com/nsdictionary/CoreArchive
本框架是隶属于MJExtension续作,我给这系列框架取了一个整体上的名字叫做:CoreModel。
CoreArchive是系列第一季,共有5季,连载中,允加群关注最新动态
成都iOS开发群:
二群:369870753(新开,新鲜着呢,快加)
一群:163865401(已爆满,加不上了)
Charlin Feng原创MJExtension续作的目的:一来是向MJExtension致敬,
二是封装大量ios开发者均迫切需要的功能,就是对数据的本地CURD。基于这个原因,
所以CoreArchive也成为了CoreModel的成员。当然CoreArchive也因为解耦的原因而独立存在。
正式开始! Let's Go!
不会写sql?别急!!!马上第二期为您解决一键全自动创表、一键CURD、
全自动检查模型动态添加字段、模型级联CURD,这一切都是全自动的,您不需要写一句Sql!
EN:Doesn’t know how to write sql? No worries. Now the second part offers you one key
automatically create table, one key CURD, automatically check model and
dynamically add field, model cascade CURD. All these things are automatic without
one sql code.
由于本人时间有限,并且此系列框架使用简单,但有一套完整的理论,文档较多,开源周期较长。
EN:Due to my time constraints and ease of use these frames,
the release cycle will be long.
第二期全自动CURD开源时间:2015年6月21日,请关注或加群(163865401)获取最新情报,谢谢
EN:The second part automatically CURD release date: 21/06/2015, so stay tuned or
join our qq group(163865401) to get the latest news, thanks a lot.
我是成都开发者,冯成林,开源是一种精神,一种分享,一种态度,或者是一种对传统模式的挑战,
这里没有炫耀,没有装逼,没有金钱,我付出的是一种精神,需要的是您的支持!
EN:I am Charlin Feng, a developer from Chengdu, China. The true spirit of open source is
an attitude and sharing even a challenge to the traditional way. There is no flaunt,
pretentious or money but all my spirits which need your support.
此系列框架的核心目标是:取代Core Data,实现一键动态缓存!
这是第一个框架,后面还是3个,你要问我为什么写这么散?还有一些朋友批判我,很多项目结构非常“混乱”,
其实,这是因为我有一个宏大的框架在我的所有Frameworks中,最核心的目的是解耦,
因为我个人觉得,如果是功能模块,我会尽量独立出来,站在解耦的核心思想中,我受益太多。希望您能理解。谢谢!
EN:The core purpose of these series frames is replace to Core Data and implement one key Dynamic Cache.
This is the first frame with other three followed. You are gonna ask me why make these frame so separately.
Even some of my friends blame me at the “chaos” of my projects’ structure. Actually,
it’s due to I got a magnificent frame in all my frameworks with a core purpose which is decoupling.
Because I believe that I will try my best to separate it if it’s a function module.
I feel I benefit from the core idea of decoupling. I hope you guys could understand. Thank you very much.
此框架是取代Core Data系列框架的第一个框架,是向MJ的MJExtension的续作以及致敬!
主要是完成MJExtension的后续工作:任意模型的一键级联动态缓存。
EN:This frame is the first one of the series frame which replace to Core Data. It’s also the sequel of
MJ’s MJExtension and to MJ to pay tribute. This frame mostly finished the follow-up work of MJExtension:
any model’s one key Cascade Dynamic Cache.
.FMDB
本框架基于FMDB,静态封装,全类方法调用,同时是线程安全的。而且您无需创建数据库对象实例并记录,绿色、简单、好用。
EN:This frame is based on FMDB and it’s static package, all classes method call, thread-safe at the same time.
You don’t need to create datebase object, instance or record. It’s a green, simple and good frame.
#import "CoreFMDB.h"
/**
* 执行一个更新语句
*
* @param sql 更新语句的sql
*
* @return 更新语句的执行结果
*/
+(BOOL)executeUpdate:(NSString *)sql;
/**
* 执行一个查询语句
*
* @param sql 查询语句sql
* @param queryResBlock 查询语句的执行结果
*/
+(void)executeQuery:(NSString *)sql queryResBlock:(void(^)(FMResultSet *set))queryResBlock;
/**
* 查询出指定表的列
*
* @param table table
*
* @return 查询出指定表的列的执行结果
*/
+(NSArray *)executeQueryColumnsInTable:(NSString *)table;
/**
* 表记录数计算
*
* @param table 表
*
* @return 记录数
*/
+(NSUInteger)countTable:(NSString *)table;
//创建表
BOOL res = [CoreFMDB executeUpdate:@"create table if not exists user(id integer primary key autoIncrement,name text not null default '',age integer not null default 0);"];
if(res){
NSLog(@"创表执行成功 create table succeed");
}else{
NSLog(@"创表执行失败 create table fails");
}
//添加数据
BOOL res2= [CoreFMDB executeUpdate:@"insert into user (name,age) values('jack',27);"];
if(res2){
NSLog(@"添加数据成功 add data succeed");
}else{
NSLog(@"添加数据失败 add data fails");
}
//查询出表所有的列
NSArray *columns = [CoreFMDB executeQueryColumnsInTable:@"user"];
NSLog(@"列信息:%@",columns);
//查询数据
[CoreFMDB executeQuery:@"select * from user;" queryResBlock:^(FMResultSet *set) {
while ([set next]) {
NSLog(@"%@-%@",[set stringForColumn:@"name"],[set stringForColumn:@"age"]);
}
}];
//计算记录数
NSUInteger count = [CoreFMDB countTable:@"user"];
NSLog(@"当前有%@条记录",@(count));
----- MJExtension续作之一:取代Core Data的利器,实现ios一键ORM的基石!
One sequel for MJExtetnsion: a better tool to replace Core Data and a cornerstone of achieving one key ORM for iOS. -----
#####1.感谢MJ Thanks MJ!
感谢杰哥!致敬MJExtension!希望大家支持杰哥的事业!
小码哥IT教育:http://www.520it.com
#####2.感谢小饭 Thanks XiaoFan!