Comments (3)
- CTPersistance是支持使用Bundle的文件的。
在CTPersistanceDataBase.m:45的地方有一个获取数据库文件的方法。
你需要根据你的数据库名构建一个target,对应的action就是"filePath",在这个target-action中返回完整的数据库文件地址即可。用法在这里
简单举个例子就是,如果你的数据库文件叫做"aaa.sqlite",那么CTPersistance会在操作table的时候,自动调度名为Target_aaa
对象的-(NSString *)Action_filePath:
方法来获得数据库具体地址,调用的时候会把数据库文件名作为参数传递过去。这个过程等价于这样的调用:
id target = [[Target_aaa alloc] init];
NSString *filePath = [target Action_filePath:@{kCTPersistanceConfigurationParamsKeyDatabaseName:@"aaa.sqlite"}];
所以你要做的事情就是在项目的任意地方,新建一个对象名叫Target_aaa
,然后给到一个-(NSString *)filePath:(NSDictionary *)params
的实现,在这个实现里面直接返回具体地址的NSString即可。
然后其他的table啊,record啊之类的操作,就都跟别的一样。如果CTPersistance调用不到这个实现,那么它就默认去library找,如果找不到就认为这个文件不存在,就会自动生成这个数据库文件。
- CTPersistance同样也是支持数据库加密的,还是在
Target_aaa
对象中,给到一个- (NSArray *)Action_secretKey:(NSDictionary *)params
的实现即可,这个实现返回的就是数据库加密的密码。如果不实现这个方法,那么就默认不加密数据库。
关于cache的事情,sqlite自己会解决的,你只管调用就好了。
from ctpersistance.
我刚刚在readme中补充了一下关于target-action的事情
from ctpersistance.
关于target对象的事情,你也不用管target对象什么时候init,你只要保证工程里有这个对象就可以了,CTPersistance会通过CTMediator,进而以runtime的方式去处理target-action的事情。
所有你要做的事情就是创建个target对象,实现好action方法,然后就放着。
就可以了。
from ctpersistance.
Related Issues (20)
- update 操作可能出现问题 HOT 3
- 同样是数据库更新错误 HOT 19
- 更新还是有问题 HOT 1
- 空值对象的改进问题 HOT 1
- CTPersistanceDatabasePool 中的一些问题 HOT 2
- CTPersistanceTable没有Merge数据的API HOT 22
- 关于bindValueList HOT 1
- 当Table中没有数据的时候,Upsert一个带有PrimaryKey的Record,失败 HOT 1
- 数据库模糊查询findAllWithWhereCondition:@"name LIKE :name",没有数据 HOT 6
- 已有未加密数据库,增加加密功能出错 HOT 8
- 数据库操作偶尔崩溃在executeWithError方法中 HOT 83
- "Include of non-modular header inside framework module" HOT 1
- crash Thread 28: EXC_BAD_ACCESS (code=1, address=0x100000000) HOT 1
- [__NSDictionaryM setObject:forKey:]: object cannot be nil (key: jsonString) crash HOT 3
- 小白问下,表文件创建后能添加新字段吗 HOT 2
- 这个数据库迁移要结合CTMediator这个三方来做吗 HOT 1
- crash:setObjectForKey: object cannot be nil
- 你个博客http://casatwy.com无法打开。求增加字段升级数据库操作文档。 HOT 3
- podfile 文件开启 use_frameworks 后 sqlite3_key 调用系统方法
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ctpersistance.