Giter Site home page Giter Site logo

Comments (3)

casatwy avatar casatwy commented on July 29, 2024
  1. 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找,如果找不到就认为这个文件不存在,就会自动生成这个数据库文件。

  1. CTPersistance同样也是支持数据库加密的,还是在Target_aaa对象中,给到一个- (NSArray *)Action_secretKey:(NSDictionary *)params的实现即可,这个实现返回的就是数据库加密的密码。如果不实现这个方法,那么就默认不加密数据库。

关于cache的事情,sqlite自己会解决的,你只管调用就好了。

from ctpersistance.

casatwy avatar casatwy commented on July 29, 2024

我刚刚在readme中补充了一下关于target-action的事情

from ctpersistance.

casatwy avatar casatwy commented on July 29, 2024

关于target对象的事情,你也不用管target对象什么时候init,你只要保证工程里有这个对象就可以了,CTPersistance会通过CTMediator,进而以runtime的方式去处理target-action的事情。

所有你要做的事情就是创建个target对象,实现好action方法,然后就放着。

就可以了。

from ctpersistance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.