Skip to content

Instantly share code, notes, and snippets.

@joshaber
Created June 27, 2012 20:05
Show Gist options
  • Save joshaber/3006514 to your computer and use it in GitHub Desktop.
Save joshaber/3006514 to your computer and use it in GitHub Desktop.
@interface MyClass : NSObject
@annotate(APIKey="object_id")
@property (nonatomic, strong) NSString *objectID;
@annotate(APIKey="full_name")
@property (nonatomic, strong) NSString *name;
@end
// The idea is that by associating metadata with those
// properties, I can automate parsing the JSON response
// from an API call into the object.
@implementation ...
- (void)parseAllTheThingsFromJSON:(NSDictionary *)JSONDictionary {
// mostly fake code:
NSDictionary *keyValuePairs = objc_getAnnotationsForProperty("objectID");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment