File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
MJExtensionDemo.xcodeproj Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -53,11 +53,8 @@ + (BOOL)mj_isReferenceReplacedKeyWhenCreatingKeyValues
53
53
}
54
54
55
55
#pragma mark - --常用的对象--
56
- static NSNumberFormatter *numberFormatter_;
57
56
+ (void )load
58
57
{
59
- numberFormatter_ = [[NSNumberFormatter alloc ] init ];
60
-
61
58
// 默认设置
62
59
[self mj_referenceReplacedKeyWhenCreatingKeyValues: YES ];
63
60
}
@@ -162,7 +159,7 @@ - (instancetype)mj_setKeyValues:(id)keyValues context:(NSManagedObjectContext *)
162
159
if (type.typeClass == [NSDecimalNumber class ]) {
163
160
value = [NSDecimalNumber decimalNumberWithString: oldValue];
164
161
} else {
165
- value = [numberFormatter_ numberFromString : oldValue];
162
+ value = @([ NSDecimalNumber decimalNumberWithString : oldValue]. doubleValue ) ;
166
163
}
167
164
168
165
// 如果是BOOL
Original file line number Diff line number Diff line change 627
627
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
628
628
CODE_SIGN_STYLE = Automatic;
629
629
INFOPLIST_FILE = MJExtensionDemo/Info.plist;
630
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
630
631
LD_RUNPATH_SEARCH_PATHS = (
631
632
"$(inherited)",
632
633
"@executable_path/Frameworks",
643
644
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
644
645
CODE_SIGN_STYLE = Automatic;
645
646
INFOPLIST_FILE = MJExtensionDemo/Info.plist;
647
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
646
648
LD_RUNPATH_SEARCH_PATHS = (
647
649
"$(inherited)",
648
650
"@executable_path/Frameworks",
Original file line number Diff line number Diff line change @@ -34,7 +34,10 @@ - (void)testJSON2Model {
34
34
@" height" : @1.55 ,
35
35
@" money" : @" 100.9" ,
36
36
@" sex" : @(SexFemale),
37
- @" gay" : @" 1"
37
+ @" gay" : @" 1" ,
38
+ @" speed" : @" 120.5" ,
39
+ @" identifier" : @" 3443623624362" ,
40
+ @" price" : @" 20.3" ,
38
41
// @"gay" : @"NO"
39
42
// @"gay" : @"true"
40
43
};
@@ -50,6 +53,9 @@ - (void)testJSON2Model {
50
53
XCTAssert (user.money .doubleValue == 100.9 );
51
54
XCTAssert (user.sex == SexFemale);
52
55
XCTAssert (user.gay == YES );
56
+ XCTAssert (user.speed == 120 );
57
+ XCTAssert (user.identifier == 3443623624362 );
58
+ XCTAssert (user.price == 20.3 );
53
59
}
54
60
55
61
#pragma mark JSON字符串 -> 模型
Original file line number Diff line number Diff line change @@ -28,4 +28,11 @@ typedef enum {
28
28
@property (assign , nonatomic ) Sex sex;
29
29
/* * 同性恋 */
30
30
@property (assign , nonatomic , getter =isGay) BOOL gay;
31
+ /* * 速度 */
32
+ @property (assign , nonatomic ) NSInteger speed;
33
+ /* * 标识 */
34
+ @property (assign , nonatomic ) long long identifier;
35
+ /* * 价格 */
36
+ @property (assign , nonatomic ) double price;
37
+
31
38
@end
You can’t perform that action at this time.
0 commit comments