joshdholtz/jsonapi-ios — pull request #5 by joshdholtz (2014-07-09 22:18:55+00:00)
Title: Fun changes

Added NSCoding, NSCopying, and format functions

### Example format block for "Date"
```objc
@interface PostResource : JSONAPIResource

@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) PeopleResource *author;
@property (nonatomic, strong) NSDate *date;
@property (nonatomic, strong) NSArray *comments;

@end

@implementation PostResource

- (NSDictionary *)mapKeysToProperties {
return @{
@"name" : @"name",
@"date" : @"Date:date",
@"links.author" : @"author",
@"links.comments" : @"comments"
};
}

@end
```

```objc
// Register formatting
[JSONAPIResourceFormatter registerFormat:@"Date" withBlock:^id(id jsonValue) {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];

NSDate *date = nil;
NSError *error = nil;
if (![dateFormatter getObjectValue:&date forString:jsonValue range:nil error:&error]) {
NSLog(@"Date '%@' could not be parsed: %@", jsonValue, error);
}

return date;
}];
```