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
5353}
5454
5555#pragma mark - --常用的对象--
56- static NSNumberFormatter *numberFormatter_;
5756+ (void )load
5857{
59- numberFormatter_ = [[NSNumberFormatter alloc ] init ];
60-
6158 // 默认设置
6259 [self mj_referenceReplacedKeyWhenCreatingKeyValues: YES ];
6360}
@@ -162,7 +159,7 @@ - (instancetype)mj_setKeyValues:(id)keyValues context:(NSManagedObjectContext *)
162159 if (type.typeClass == [NSDecimalNumber class ]) {
163160 value = [NSDecimalNumber decimalNumberWithString: oldValue];
164161 } else {
165- value = [numberFormatter_ numberFromString : oldValue];
162+ value = @([ NSDecimalNumber decimalNumberWithString : oldValue]. doubleValue ) ;
166163 }
167164
168165 // 如果是BOOL
Original file line number Diff line number Diff line change 627627 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
628628 CODE_SIGN_STYLE = Automatic;
629629 INFOPLIST_FILE = MJExtensionDemo/Info.plist;
630+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
630631 LD_RUNPATH_SEARCH_PATHS = (
631632 "$(inherited)",
632633 "@executable_path/Frameworks",
643644 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
644645 CODE_SIGN_STYLE = Automatic;
645646 INFOPLIST_FILE = MJExtensionDemo/Info.plist;
647+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
646648 LD_RUNPATH_SEARCH_PATHS = (
647649 "$(inherited)",
648650 "@executable_path/Frameworks",
Original file line number Diff line number Diff line change @@ -34,7 +34,10 @@ - (void)testJSON2Model {
3434 @" height" : @1.55 ,
3535 @" money" : @" 100.9" ,
3636 @" sex" : @(SexFemale),
37- @" gay" : @" 1"
37+ @" gay" : @" 1" ,
38+ @" speed" : @" 120.5" ,
39+ @" identifier" : @" 3443623624362" ,
40+ @" price" : @" 20.3" ,
3841 // @"gay" : @"NO"
3942 // @"gay" : @"true"
4043 };
@@ -50,6 +53,9 @@ - (void)testJSON2Model {
5053 XCTAssert (user.money .doubleValue == 100.9 );
5154 XCTAssert (user.sex == SexFemale);
5255 XCTAssert (user.gay == YES );
56+ XCTAssert (user.speed == 120 );
57+ XCTAssert (user.identifier == 3443623624362 );
58+ XCTAssert (user.price == 20.3 );
5359}
5460
5561#pragma mark JSON字符串 -> 模型
Original file line number Diff line number Diff line change @@ -28,4 +28,11 @@ typedef enum {
2828@property (assign , nonatomic ) Sex sex;
2929/* * 同性恋 */
3030@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+
3138@end
You can’t perform that action at this time.
0 commit comments