CoreData - Mogenerator 的使用

Why use Mogenerator instead of XCode directly:

Mogenerator is a program that builds two custom classes for each entity in a Core Data model: a machine version and a human version.

This command-line tool, given an .xcdatamodel file, will generate two classes per entity. The first class (machine version), _MyEntity, is intended solely for machine consumption and will be continuously overwritten to stay in sync with your data model. The second class (human version), MyEntity, subclasses _MyEntity, won't ever be overwritten and is a great place to put your custom logic.

 

The machine version handles the basic behavior you need from a custom Core Data class (like Xcode’s generated classes). It is expected that the machine version will get overwritten every time the model changes, so you should not make any changes here(they will be lost).

The human version extends the machine version and is the class you modify for your own app specific behavior.

 

Steps to generator the Machine Files and Human Files for xcodemodel database.

1. Download Mogenerator from:

             https://github.com/rentzsch/mogenerator/

         I used latest version v1.26: Thu Apr 12 2012download

2. Install the mogenerator-1.26.dmg from your download folder.

3. Start the console and go the resource folder

4. Run the command below to generator the files:

     mogenerator -m RobertLiu.xcdatamodeld/RobertLiu.xcdatamodel -M Model -H Entities

    If your application need support ARC, you need to use below command:

    mogenerator --template-var arc=true -m RobertLiu.xcdatamodeld/RobertLiu.xcdatamodel -M Model -H Entities

5. You will see the results:

     xxx machine files and xxx human files generated.

 

Notes:

1. Beside the command line, mogenerator supports the xmod, which is integrated with Xcode.  here is the reference to setup xmod.

             http://raptureinvenice.com/getting-started-with-mogenerator/

 

2. In case you want to uninstall mogenerator and try the previous version, such asv1.25: Thu Feb 16 2012 download, please just remove below files:

             •  /usr/bin/mogenerator

             •  /private/var/db/receipts/com.rentzsch.mogenerator.bom          

             •  /private/var/db/receipts/com.rentzsch.mogenerator.plist

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值