Skip to content

Commit 2c8af22

Browse files
committed
Updated to include non null string transformer
1 parent 14a9c19 commit 2c8af22

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

Realm+JSON.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Realm+JSON'
3-
s.version = '0.2.9'
3+
s.version = '0.2.10'
44
s.ios.deployment_target = '7.0'
55
s.osx.deployment_target = '10.9'
66
s.license = { :type => 'MIT', :file => 'LICENSE' }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// MCJSONNonNullStringTransformer.h
3+
// Pods
4+
//
5+
// Created by Matthew Cheok on 23/5/15.
6+
//
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface MCJSONNonNullStringTransformer : NSValueTransformer
12+
13+
+ (instancetype)valueTransformer;
14+
15+
@end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// MCJSONNonNullStringTransformer.m
3+
// Pods
4+
//
5+
// Created by Matthew Cheok on 23/5/15.
6+
//
7+
//
8+
9+
#import "MCJSONNonNullStringTransformer.h"
10+
11+
@implementation MCJSONNonNullStringTransformer
12+
13+
+ (instancetype)valueTransformer {
14+
return [[self alloc] init];
15+
}
16+
17+
+ (Class)transformedValueClass {
18+
return [NSString class];
19+
}
20+
21+
+ (BOOL)allowsReverseTransformation {
22+
return YES;
23+
}
24+
25+
- (id)transformedValue:(id)value {
26+
if (value && ![value isKindOfClass:[NSNull class]]) {
27+
return value;
28+
}
29+
else {
30+
return @"";
31+
}
32+
}
33+
34+
- (id)reverseTransformedValue:(id)value {
35+
return value;
36+
}
37+
38+
@end

0 commit comments

Comments
 (0)