开发者

iPhone Core Data Generated Model Files and Custom Code

开发者 https://www.devze.com 2022-12-08 20:48 出处:网络
After I\'ve generated the interface/implementation files for entities of a model file in XCode, I\'ve not found a way to keep any custom code (validation methods, etc...) I\'ve added to those generate

After I've generated the interface/implementation files for entities of a model file in XCode, I've not found a way to keep any custom code (validation methods, etc...) I've added to those generated files, given the scenario where I've added an attribute to a model entity and need to re-generate the interface/implementation files. Does anyone know of a way to make this happen? I've just been doing the 开发者_StackOverflow社区copy/paste shuffle, but there has to be a better way.


Assuming that you're only talking about adding methods, and not new instance variables, I'd recommend using Objective C categories to add additional behavior to your model classes. Here's a blog post along the same lines.


Use mogenerator, which uses the Generation Gap design pattern to prevent your customizations from being overwritten when the code is re-generated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号