From 9b661760f944a9b6de4b2df8967670975c0530ca Mon Sep 17 00:00:00 2001 From: mrzsun Date: Sun, 15 May 2016 17:01:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E9=99=85=E5=BC=80=E5=8F=91=E4=B8=AD?= =?UTF-8?q?=E6=9C=89=E5=8F=AF=E8=83=BD=E5=90=8E=E5=8F=B0=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9A=84json=E6=95=B0=E6=8D=AE=E5=AD=97=E6=AE=B5=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E5=80=BC=E6=98=AF=EF=BC=8C=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E5=88=B0ios=E7=9A=84=E5=AD=97=E5=85=B8=E9=87=8C?= =?UTF-8?q?=E9=9D=A2=E5=B0=B1=E6=98=AF=E4=B8=80=E4=B8=AANSNull=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=EF=BC=8C=E8=BF=99=E9=87=8C=E5=81=9A=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=88=A4=E6=96=AD=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=98=AFNSNUll=E7=9A=84=E5=AE=9E=E4=BE=8B=E5=B0=B1=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E6=88=90nil=E3=80=82=E5=8F=AF=E4=BB=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8Dcrash=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcschemes/Reflect.xcscheme | 101 ++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 27 +++++ .../Reflect/Dict2Model/Reflect+Parse.swift | 24 ++++- 3 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 Reflect.xcodeproj/xcuserdata/marcosun.xcuserdatad/xcschemes/Reflect.xcscheme create mode 100644 Reflect.xcodeproj/xcuserdata/marcosun.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/Reflect.xcodeproj/xcuserdata/marcosun.xcuserdatad/xcschemes/Reflect.xcscheme b/Reflect.xcodeproj/xcuserdata/marcosun.xcuserdatad/xcschemes/Reflect.xcscheme new file mode 100644 index 0000000..b99fb17 --- /dev/null +++ b/Reflect.xcodeproj/xcuserdata/marcosun.xcuserdatad/xcschemes/Reflect.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Reflect.xcodeproj/xcuserdata/marcosun.xcuserdatad/xcschemes/xcschememanagement.plist b/Reflect.xcodeproj/xcuserdata/marcosun.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..c77f066 --- /dev/null +++ b/Reflect.xcodeproj/xcuserdata/marcosun.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + Reflect.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 89B833691B842549002C60EB + + primary + + + 89B8337E1B84254A002C60EB + + primary + + + + + diff --git a/Reflect/Reflect/Dict2Model/Reflect+Parse.swift b/Reflect/Reflect/Dict2Model/Reflect+Parse.swift index 706fc23..768fbca 100755 --- a/Reflect/Reflect/Dict2Model/Reflect+Parse.swift +++ b/Reflect/Reflect/Dict2Model/Reflect+Parse.swift @@ -66,7 +66,18 @@ extension Reflect{ model.setValue(dict[key]?.boolValue, forKeyPath: name) }else{ - model.setValue(dict[key], forKeyPath: name) + + var dictValue = dict[key] + + if let tmp = dictValue { + + if tmp.isEqual(NSNull.init()) { + + dictValue = nil + } + } + + model.setValue(dictValue, forKeyPath: name) } @@ -75,7 +86,16 @@ extension Reflect{ //这里是模型 //首选判断字典中是否有值 - let dictValue = dict[key] + + var dictValue = dict[key] + + if let tmp = dictValue { + + if tmp.isEqual(NSNull.init()) { + + dictValue = nil + } + } if dictValue != nil { //字典中有模型