且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Mogenerator和Xcode 4的优点/缺点

更新时间:2023-08-21 19:41:04

这个文章详细说明了如何在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.