diff --git a/Realm+JSON.podspec b/Realm+JSON.podspec index 9db47e5..483e8c6 100644 --- a/Realm+JSON.podspec +++ b/Realm+JSON.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Realm+JSON' - s.version = '0.2.9' + s.version = '0.2.10' s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/Realm+JSON/MCJSONNonNullStringTransformer.h b/Realm+JSON/MCJSONNonNullStringTransformer.h new file mode 100644 index 0000000..59b219c --- /dev/null +++ b/Realm+JSON/MCJSONNonNullStringTransformer.h @@ -0,0 +1,15 @@ +// +// MCJSONNonNullStringTransformer.h +// Pods +// +// Created by Matthew Cheok on 23/5/15. +// +// + +#import + +@interface MCJSONNonNullStringTransformer : NSValueTransformer + ++ (instancetype)valueTransformer; + +@end diff --git a/Realm+JSON/MCJSONNonNullStringTransformer.m b/Realm+JSON/MCJSONNonNullStringTransformer.m new file mode 100644 index 0000000..34c7d7a --- /dev/null +++ b/Realm+JSON/MCJSONNonNullStringTransformer.m @@ -0,0 +1,38 @@ +// +// MCJSONNonNullStringTransformer.m +// Pods +// +// Created by Matthew Cheok on 23/5/15. +// +// + +#import "MCJSONNonNullStringTransformer.h" + +@implementation MCJSONNonNullStringTransformer + ++ (instancetype)valueTransformer { + return [[self alloc] init]; +} + ++ (Class)transformedValueClass { + return [NSString class]; +} + ++ (BOOL)allowsReverseTransformation { + return YES; +} + +- (id)transformedValue:(id)value { + if (value && ![value isKindOfClass:[NSNull class]]) { + return value; + } + else { + return @""; + } +} + +- (id)reverseTransformedValue:(id)value { + return value; +} + +@end