Add constant structs for the property names #72

Merged
merged 1 commit into from Aug 30, 2011

Conversation

Projects
None yet
4 participants
@danielctull
Contributor

danielctull commented Aug 30, 2011

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.

Add constant structs for the property names
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

This comment has been minimized.

Show comment
Hide comment
@extremeboredom

extremeboredom Aug 30, 2011

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.

Contributor

extremeboredom commented Aug 30, 2011

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

This comment has been minimized.

Show comment
Hide comment
@danielctull

danielctull Aug 30, 2011

Contributor

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!)

Contributor

danielctull commented Aug 30, 2011

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

Merge pull request #72 from danielctull/master
[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

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Aug 30, 2011

Owner

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

Owner

rentzsch commented Aug 30, 2011

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

Merge pull request #72 from danielctull/mogenerator
---

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

This comment has been minimized.

Show comment
Hide comment
@jdmuys

jdmuys Dec 8, 2011

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

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

This comment has been minimized.

Show comment
Hide comment
@danielctull

danielctull Dec 8, 2011

Contributor

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

Contributor

danielctull commented Dec 8, 2011

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

@rentzsch

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Dec 8, 2011

Owner

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

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

Merge pull request #72 from danielctull/mogenerator
---

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

Merge pull request #72 from danielctull/master
[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