Mogenerator和Xcode 4的优点/缺点 [英] Mogenerator and Xcode 4 advantages/disadvantages

查看:97
本文介绍了Mogenerator和Xcode 4的优点/缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对核心数据集成有点陌生,并发现了许多代码示例和教程。一些建议使用Mogenerator生成实体子类。这是更老的方法吗?

I am somewhat new to core data integration and have found many code samples and tutorials. Some suggest using Mogenerator to generate entity subclasses. Is this an older approach?

Xcode允许为没有第三方工具的实体生成子类。

Xcode allows one to generate subclasses for entities without a third party tool. Can anyone offer reasons as to why I would choose to use Mogenerator over the embedded Xcode tool for generating entity subclasses?

推荐答案

这个< a href =http://raptureinvenice.com/getting-started-with-mogenerator/ =nofollow>文章详细说明了如何在XCode4中使用mogenerator,以及为什么要。

This article has a detailed explanation of how to use mogenerator with XCode4, and why you would want to.

在开发应用程序时,您可能会向生成的实体类添加自己的自定义方法( NSManagedObject 子类)。但是,当您运行 xctool 生成类时,所有更改都会被覆盖并丢失!

In developing your app you're likely to add your own custom methods to the generated entity classes (NSManagedObject subclasses). But when you run xctool to generate the classes, all your changes are overwritten and lost!

Mogenerator生成一个对每个实体的类 - 一个稳定的机器类,可以在您进行更改时从模型中重新生成,以及一个可以编辑和添加方法的机器类的人类子类。

Mogenerator generates a pair of classes for each entity - one stable 'machine' class which can be re-generated from the model as you make changes, and one 'human' subclass of the machine class which you can edit and add methods to.

我建议添加目标&构建阶段到你的Xcode项目,这将在构建时生成你的实体类,所以你永远不必记得手动运行mogenerator。

I recommend adding a target & build phase to your Xcode project which will generate your entity classes at build time, so you never have to remember to run mogenerator manually.

此外,mogenerator将包含您的权限属性的const结构添加到生成的类中,因此您可以避免在谓词等中使用硬编码的字符串。

In addition, mogenerator adds const structs containing the attributes of your entitites to the generated classes, so you can avoid using hard-coded strings in your predicates etc.

这篇关于Mogenerator和Xcode 4的优点/缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆