Skip to content

Instantly share code, notes, and snippets.

@ejknapp
Created November 27, 2012 23:58
Show Gist options
  • Select an option

  • Save ejknapp/4158052 to your computer and use it in GitHub Desktop.

Select an option

Save ejknapp/4158052 to your computer and use it in GitHub Desktop.
#import "Contact.h"
@interface Contact ()
@property (strong) NSString *firstName;
@property (strong) NSString *lastName;
@property (strong) NSString *email;
@property (strong) NSString *cell;
@end
@implementation Contact
- (id)initWithJSONDictionary:(NSDictionary *)jsonDictionary
{
self = [self init];
if (self) {
_firstName = jsonDictionary[@"firstName"];
_lastName = jsonDictionary[@"lastName"];
_email = jsonDictionary[@"email"];
_cell = jsonDictionary[@"cell"];
}
return self;
}
- (NSDictionary *)jsonDictionary
{
NSDictionary *json = @{
@"firstName" : [self firstName],
@"lastName" : [self lastName],
@"email" : [self email],
@"cell" : [self cell]
};
return json;
}
- (NSString *)fullName
{
return [NSString stringWithFormat:@"%@, %@", [self lastName], [self firstName]];
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<Contact: %@ %@, %@, %@>",
[self firstName], [self lastName], [self email], [self cell]];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment