Skip to content

Commit f1e135d

Browse files
committed
代码优化
1 parent 4dd6084 commit f1e135d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

LKDBHelper/Helper/NSObject+LKModel.m

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,9 @@ -(void)modelSetValue:(LKDBProperty *)property value:(id)value
242242
///参试获取属性的Class
243243
Class columnClass = NSClassFromString(property.propertyType);
244244

245-
id modelValue = value;
246-
if([value length] == 0)
247-
{
248-
modelValue = nil;
249-
}
250-
else if(columnClass == nil)
245+
id modelValue = nil;
246+
247+
if(columnClass == nil)
251248
{
252249
///当找不到 class 时,就是 基础类型 int,float CGRect 之类的
253250

@@ -313,10 +310,19 @@ -(void)modelSetValue:(LKDBProperty *)property value:(id)value
313310
modelValue = [NSValue valueWithRange:range];
314311
}
315312
#endif
313+
///如果都没有值 默认给个0
314+
if(modelValue == nil)
315+
{
316+
modelValue = [NSNumber numberWithInt:0];
317+
}
318+
}
319+
else if([value length] == 0)
320+
{
321+
//为了不继续遍历
316322
}
317323
else if([columnClass isSubclassOfClass:[NSString class]])
318324
{
319-
325+
modelValue = value;
320326
}
321327
else if([columnClass isSubclassOfClass:[NSNumber class]])
322328
{

0 commit comments

Comments
 (0)