-
Notifications
You must be signed in to change notification settings - Fork 43
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
Ability to name Objective-C property differently than its JSON key #33
Comments
@christianselig - I'm assuming the convention you are trying to keep is the property suffix represented as Your understanding of how plank derives property names is almost correct.
Thanks for the suggestion and it has certainly come up internally at Pinterest before. Historically we've had a goal of keeping scheme keys 1:1 with the server-side specification to enforce the creation of reasonable keys for our API JSON responses. A workaround we've used internally is to declare a property getter on a category on your model class which would look something like the below code. // Generated model interface
@interface MyModel
@property (nonatomic, strong, readonly) NSURL *imgURL;
@end
// Your category
@interface MyModel(Aliases)
@property (nonatomic, strong, readonly) NSURL *imageURL;
@end
@implementation MyModel(Aliases)
- (NSURL *)imageURL
{
return self.imgURL;
}
@end |
@rahul-malik Your assumption was correct! And awesome, that's terrific and should suffice fine, thanks for the prompt response and appreciate the library. :) |
Thanks @christianselig! Let me know if you run into any issues :) |
Say I'm interfacing with an API that has an
img_url
key. If I'm understanding everything correctly, plank would incorporate that asimgUrl
. It'd be nice to be able to specify it asimageURL
to be more inline with Objective-C convention (I don't have server-side control over this API, so I can't change it there).Or is there a goal to keep it absolutely 1:1 with the server-side spec?
The text was updated successfully, but these errors were encountered: