Code Monkey home page Code Monkey logo

savedata's Introduction

数据存储的几种方式 sql,FMDB,CoreData CoreData:ios5之后才出现的一个框架,它提供了对象-关系型映射(ORM)的功能,即能够将OC对象转化为数据,保存在SQLite数据文件中,也能够将保存在数据库中的数据还原成OC对象。在此数据操作期间,我们不需要编写任何SQL语句.但底层实现还是SQL 模型文件: 在CoreData,需要进行映射的对象成为实体(entity),而且需要使用CoreData的模型文件来描述app中的所有实体和实体属性

xcode 项目中设置可以看到对应的SQLite的语句: 1:打开Product,点击EditScheme 2.点击Arguments,在ArgumentsPassed On Launch 中添加两项 1>-com.apple.CoreData.SQLDebug 2>1

数据库迁移步骤 1.选中Model.xcdatamodeld模型文件,在顶部菜单栏中选择:Editor->Add Model Version,添加一个新的模型文件Model2.xcdatamodeld 2.然后在xcode右侧导航栏中,Mode Version中选择要切换的模型文件Model2 3.在创建数据持久调度的代码中添加option选项 [_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:sqlLiteURL options:nil error:&error];

修改为: //数据库版本迁移 NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES};

[_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:sqlLiteURL options:options error:&error];

savedata's People

Contributors

1024tobe avatar rongyaoheika avatar

Watchers

James Cloos avatar  avatar

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.