Created
October 25, 2012 14:58
-
-
Save stevenhuey/3953093 to your computer and use it in GitHub Desktop.
After Mantle
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
@implementation CBCosmDatastream | |
#pragma mark - Mantle | |
+ (NSDictionary *)externalRepresentationKeyPathsByPropertyKey | |
{ | |
return [super.externalRepresentationKeyPathsByPropertyKey mtl_dictionaryByAddingEntriesFromDictionary:@{ | |
@"datastreamId": @"id", | |
@"updated": @"at", | |
@"value": @"current_value", | |
@"minValue": @"min_value", | |
@"maxValue": @"max_value" | |
}]; | |
} | |
#pragma mark - KVC | |
- (void)setValue:(id)value forKey:(NSString*)key | |
{ | |
if ([key isEqualToString:@"datapoints"]) | |
{ | |
if ([value isKindOfClass:[NSArray class]]) | |
{ | |
NSArray* values = (NSArray*)value; | |
NSMutableArray* datapoints = [NSMutableArray arrayWithCapacity:[values count]]; | |
for (NSDictionary* attributes in values) | |
{ | |
CBCosmDatapoint* datapoint = [[CBCosmDatapoint alloc] initWithAttributes:attributes]; | |
[datapoints addObject:datapoint]; | |
} | |
_datapoints = datapoints; | |
} | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment