Skip to content

Commit 378a0ec

Browse files
committed
a little problem for array
a little problem for array
1 parent be4d2a4 commit 378a0ec

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

MJExtension.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 = "MJExtension"
3-
s.version = "3.0.4"
3+
s.version = "3.0.5"
44
s.ios.deployment_target = '6.0'
55
s.osx.deployment_target = '10.8'
66
s.summary = "A fast and convenient conversion between JSON and model"

MJExtension/MJPropertyKey.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ - (id)valueInObject:(id)object
1515
if ([object isKindOfClass:[NSDictionary class]] && self.type == MJPropertyKeyTypeDictionary) {
1616
return object[self.name];
1717
} else if ([object isKindOfClass:[NSArray class]] && self.type == MJPropertyKeyTypeArray) {
18-
return ((NSArray *)object).count ? object[self.name.intValue] : nil;
18+
NSArray *array = object;
19+
NSUInteger index = self.name.intValue;
20+
if (index < array.count) return array[index];
21+
return nil;
1922
}
2023
return nil;
2124
}

MJExtension/NSObject+MJKeyValue.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,10 @@ - (NSMutableDictionary *)mj_keyValuesWithKeys:(NSArray *)keys ignoredKeys:(NSArr
352352
}
353353

354354
if ([tempInnerContainer isKindOfClass:[NSMutableArray class]]) {
355+
NSMutableArray *tempInnerContainerArray = tempInnerContainer;
355356
int index = nextPropertyKey.name.intValue;
356-
while ([tempInnerContainer count] < index + 1) {
357-
[tempInnerContainer addObject:[NSNull null]];
357+
while (tempInnerContainerArray.count < index + 1) {
358+
[tempInnerContainerArray addObject:[NSNull null]];
358359
}
359360
}
360361

0 commit comments

Comments
 (0)