Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template hooks, or option to insert "base class" before or after generated classes. #149

Closed
steveluscher opened this issue Mar 4, 2013 · 2 comments

Comments

@steveluscher
Copy link

I recently had the desire to add a +findOrCreate type method to MyManagedObject "base class". In there, however, I wanted to make use of [self entityName]. Since +entityName isn't declared until later, this threw a compiler warning, of course.

For now, I can just do [(id)self performSelector:@selector(entityName)], but it got me thinking that it would be nice to either have template hooks in motemplates, so that I can use the built-in templates but #include custom code in each section, or to be able to specify whether my "base class" is the superclass of, or a subclass of the machine-generated _Model files.

What do you think about that?

@steveluscher
Copy link
Author

Aaaaaaand… I just found this.

--base-class-import TEXT        Imports base class as #import TEXT

I trust that will accomplish what I hope it will?

@rentzsch
Copy link
Owner

rentzsch commented Mar 4, 2013

I would just put

@interface NSManagedObject (entityName)
+ (NSString*)entityName;
@end

at the start of MyManagedObject.m to silence the compiler warning.

I think you're asking for template inherence, which MiscMerge doesn't offer, so mogenerator can't offer.

I don't think --base-class-import is the droid you're looking for. See #135 for the back-story and its intended use.

@rentzsch rentzsch closed this as completed Mar 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants