简体   繁体   English

如何从sqlite文件生成Objective-C类

[英]How to generate objective-c classes from sqlite file

I have this little issue with creating my objective-c models from an sqlite database file, I have already tried Vertabelo but it's limited to 100 tables in the free account (I do have more tables 147), and it seems like 'Objective-C Query Builder' ORM is not working anymore. 我从sqlite database文件创建我的Objective-C模型时遇到了一个小问题,我已经尝试过Vertabelo,但是免费帐户中的表仅限于100个表(我确实有更多表147),而且看起来像“ Objective-C查询生成器的ORM不再起作用。

Does anyone have any solution or proposition, thanks in advance. 有没有人有任何解决方案或主张,在此先感谢。

Ok, this is how you can wrap sql to Objective-C Objects . 好的,这是将sql包装到Objective-C 对象的方法

Take a look at this solution. 看一下这个解决方案。 Useful for me. 对我有用。

SQLiteManager is a simple Class "wrapper" to use SQLite3 within iOS SDK. SQLiteManager是在iOS SDK中使用SQLite3的简单类“包装器”。 It provides methods to: 它提供以下方法:

  • connect/create a database in your documents app folder 在您的文档应用文件夹中连接/创建数据库
  • do a simple query 做一个简单的查询
  • get rows in NSDictionary format 获取NSDictionary格式的行
  • close the connection 关闭连接
  • dump your data in sql dump format 以sql dump格式转储数据

After that use NSDictionaries to create the models/classes you want to achieve. 之后,使用NSDictionaries创建要实现的模型/类

You could generate model classes based on your SQLite 3 database's tables and views using my LabQLite Model Generator . 您可以使用LabQLite Model Generator基于SQLite 3数据库的表和视图生成模型类。

Then, simply setup my LabQLite library in your Xcode project to give life to those generated model classes. 然后,只需在Xcode项目中设置我的LabQLite库即可赋予这些生成的模型类以生命。 Your model classes will have an Active Record pattern feel to them with full CRUD control... and there are a bunch of tricks that you can do at the high and low levels... and anywhere in-between. 通过完全的CRUD控制,您的模型类将具有Active Record模式的感觉...并且您可以在高低级别之间以及之间的任何位置进行一系列操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM