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

Add constant structs for the property names #72

Merged
merged 1 commit into from
Aug 30, 2011
Merged

Add constant structs for the property names #72

merged 1 commit into from
Aug 30, 2011

Conversation

danielctull
Copy link
Contributor

Sampling Mike Ash's post about namespaced constants (http://www.mikeash.com/pyblog/friday-qa-2011-08-19-namespaced-constants-and-functions.html), this adds the generation of constant structs to access the attribute, relationship and fetched property names. This makes sure that when you're creating a fetch request, you can use these values to guarantee their existence.

Sampling Mike Ash's post about namespaced constants (http://www.mikeash.com/pyblog/friday-qa-2011-08-19-namespaced-constants-and-functions.html), this adds the generation of constant structs to access the attribute, relationship and fetched property names. This makes sure that when you're creating a fetch request, you can use these values to guarantee their existence.
@extremeboredom
Copy link
Contributor

Sounds like an awesome addition, looking forward to using it.

Should it be optionally enabled perhaps, instead of always on? Should be simple with template vars.

@danielctull
Copy link
Contributor Author

I did wonder whether it should be optional, though I can't see too much harm in generating them and not using them, especially if it removes a preference. (Though I know the command line types love options!)

rentzsch added a commit that referenced this pull request Aug 30, 2011
[NEW] [Mike-Ash-style](http://www.mikeash.com/pyblog/friday-qa-2011-08-19-namespaced-constants-and-functions.html) namespaced constants for entity attribute names and relationships. Allows you to write things like `[mo valueForKey:PersonMOAttributes.hairColor]` instead of `[mo valueForKey:@"hairColor"]`. The main benefit here is the compile-time errors when the `hairColor` attribute is removed or renamed. (Daniel Tull)
@rentzsch rentzsch merged commit 778bf54 into rentzsch:master Aug 30, 2011
@rentzsch
Copy link
Owner

I'm going to have it always-on. I don't see a big win being able to turn it off.

jonmarimba pushed a commit to jonmarimba/mogenerator that referenced this pull request Nov 1, 2011
---

Sampling Mike Ashs post about namespaced constants (http://www.mikeash.com/pyblog/friday-qa-2011-08-19-namespaced-constants-and-functions.html), this adds the generation of constant structs to access the attribute, relationship and fetched property names. This makes sure that when youre creating a fetch request, you can use these values to guarantee their existence.
@jdmuys
Copy link

jdmuys commented Dec 8, 2011

These added structs are incompatible with ARC. I get compiler errors "error: ARC forbids Objective-C objects in structs or unions"

@danielctull
Copy link
Contributor Author

Are you using the ARC flag (--template-var arc=true)? I've been using them solely with ARC since August. :)

@rentzsch
Copy link
Owner

rentzsch commented Dec 8, 2011

@jdmuys, @danielctull thanks for clearing this up, it will go in v1.24's changelog

ddrccw pushed a commit to ddrccw/mogenerator that referenced this pull request Jan 20, 2014
---

Sampling Mike Ashs post about namespaced constants (http://www.mikeash.com/pyblog/friday-qa-2011-08-19-namespaced-constants-and-functions.html), this adds the generation of constant structs to access the attribute, relationship and fetched property names. This makes sure that when youre creating a fetch request, you can use these values to guarantee their existence.
ddrccw pushed a commit to ddrccw/mogenerator that referenced this pull request Jan 20, 2014
[NEW] [Mike-Ash-style](http://www.mikeash.com/pyblog/friday-qa-2011-08-19-namespaced-constants-and-functions.html) namespaced constants for entity attribute names and relationships. Allows you to write things like `[mo valueForKey:PersonMOAttributes.hairColor]` instead of `[mo valueForKey:@"hairColor"]`. The main benefit here is the compile-time errors when the `hairColor` attribute is removed or renamed. (Daniel Tull)
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

Successfully merging this pull request may close these issues.

4 participants