Last active
August 29, 2015 13:57
-
-
Save akhenakh/9442985 to your computer and use it in GitHub Desktop.
Mantle conversion for timestamped json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (NSValueTransformer *)publictionDateJSONTransformer { | |
return [MTLValueTransformer transformerUsingForwardBlock:^(NSNumber *timestamp, BOOL *success, NSError **error){ | |
return [NSDate dateWithTimeIntervalSince1970:[timestamp doubleValue]]; | |
} reverseBlock:^(NSDate *date, BOOL *success, NSError **error) { | |
return [NSNumber numberWithDouble:[date timeIntervalSince1970]]; | |
}]; | |
} |
thx
updated with new transformerUsingForwardBlock
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please fix gist