ios开发数据库版本迁移手动更新迭代和自动更新迭代艺术(二)

      由于大家都热衷于对ios开发数据库版本迁移手动更新迭代和自动更新迭代艺术(一)的浏览下面我分享下我的源文件git仓库:

    用法(这边我是对缓存的一些操作不需要可以省去):https://github.com/PureLovePeter/DataCashe.git

/**

 缓存的原理数据用户操作

 @param tableName 表名称

 @param statusId 状态

 @param dropDown 是不是下啦刷新

 @return 判断现在的状态

 */

+ (int)jugeTableNeedUpdateWithTableName:(NSString *)tableName statusId:(int)statusId  dropDown:(BOOL)dropDown{

    CacheFMDB *cache = [CacheFMDB sharedCacheFMDB];

    if (statusId != 0) {

        if (dropDown) {

            return 1;//请求网络,需要进行表的插入数据操作

        }

        //时间到期需要更新

        BOOL NeedUp = [cache isNeedUpdateCandidateTableWithStatusId:statusId];

        //存不存在表

        BOOL dataUp = [cache jugeTableIsExistWithStatusId:statusId];

        //如果表不存在

        if (!dataUp&&!NeedUp) {

            return 1;//请求网络,需要进行表的插入数据操作

        }else if(dataUp&&!NeedUp){//如果表存在,时间没到期

            return 2;//不需要进行网络操作,直接从数据库那

        }else if(dataUp&&NeedUp){//如果表存在,时间到期

            return 3;//需要进行网络操作,显示并且存储数据库

        }

    }else{

        if (dropDown) {

            return 1;//请求网络,需要进行表的插入数据操作

        }

        BOOL NeedUp = [cache isNeedUpdateTableName:tableName];

        BOOL dataUp = [cache jugeTableIsExistWithName:tableName];

        //如果表不存在

        if (!dataUp&&!NeedUp) {

            return 1;//请求网络,需要进行表的插入数据操作

        }else if(dataUp&&!NeedUp){//如果表存在,时间没到期

            return 2;//不需要进行网络操作,直接从数据库那

        }else if(dataUp&&NeedUp){//如果表存在,时间到期

            return 3;//需要进行网络操作,显示并且存储数据库

        }

    }

    return -1;

}

       

   

    

原文地址:https://www.cnblogs.com/PeterWolf/p/7272545.html