diff --git a/librato-iOS/Metrics/LibratoMetric.m b/librato-iOS/Metrics/LibratoMetric.m index c5a2885..ed7b44a 100644 --- a/librato-iOS/Metrics/LibratoMetric.m +++ b/librato-iOS/Metrics/LibratoMetric.m @@ -69,9 +69,9 @@ + (NSDictionary *)JSONKeyPathsByPropertyKey + (NSValueTransformer *)measureTimeJSONTransformer { - return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSNumber *epoch) { + return [MTLValueTransformer transformerUsingForwardBlock:^id(NSNumber *epoch, BOOL *success, NSError **error) { return [NSDate dateWithTimeIntervalSince1970:epoch.integerValue]; - } reverseBlock:^id(NSDate *date) { + } reverseBlock:^id(NSDate *date, BOOL *success, NSError **error) { return @(floor(date.timeIntervalSince1970)); }]; } @@ -79,10 +79,10 @@ + (NSValueTransformer *)measureTimeJSONTransformer + (NSValueTransformer *)nameJSONTransformer { - return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSString *name) { + return [MTLValueTransformer transformerUsingForwardBlock:^id(NSString *name, BOOL *success, NSError **error) { NSAssert(name.length > 0, @"Measurements must be named"); return name.alm_sanitizedForMetric; - } reverseBlock:^id(NSString *name) { + } reverseBlock:^id(NSString *name, BOOL *success, NSError **error) { return name.alm_sanitizedForMetric; }]; } @@ -90,9 +90,9 @@ + (NSValueTransformer *)nameJSONTransformer + (NSValueTransformer *)sourceJSONTransformer { - return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSString *source) { + return [MTLValueTransformer transformerUsingForwardBlock:^id(NSString *source, BOOL *success, NSError **error) { return source.alm_sanitizedForMetric; - } reverseBlock:^id(NSString *source) { + } reverseBlock:^id(NSString *source, BOOL *success, NSError **error) { return (source.length ? source.alm_sanitizedForMetric : nil); }]; } @@ -100,10 +100,10 @@ + (NSValueTransformer *)sourceJSONTransformer + (NSValueTransformer *)valueJSONTransformer { - return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSNumber *value) { + return [MTLValueTransformer transformerUsingForwardBlock:^id(NSNumber *value, BOOL *success, NSError **error) { NSAssert([self.class isValidValue:value], @"Boolean is not a valid metric value"); return value; - } reverseBlock:^id(NSNumber *value) { + } reverseBlock:^id(NSNumber *value, BOOL *success, NSError **error) { return value; }]; } @@ -113,7 +113,7 @@ + (NSValueTransformer *)valueJSONTransformer - (NSDictionary *)JSONDictionary { NSArray *nonNullableKeys = @[@"source"]; - __block NSMutableDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:self].mutableCopy; + __block NSMutableDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:self error:nil].mutableCopy; [nonNullableKeys enumerateObjectsUsingBlock:^(NSString *key, NSUInteger idx, BOOL *stop) { if ([jsonDict.allKeys containsObject:key] && (jsonDict[key] == NSNull.null || jsonDict[key] == nil)) {