Skip to content

Commit f069f92

Browse files
authored
some typo (#773)
1 parent c272a32 commit f069f92

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

MJExtension/MJProperty.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ - (void)setOriginKey:(id)originKey forClass:(Class)c
147147
if ([originKey isKindOfClass:[NSString class]]) { // 字符串类型的key
148148
NSArray *propertyKeys = [self propertyKeysWithStringKey:originKey];
149149
if (propertyKeys.count) {
150-
[self setPorpertyKeys:@[propertyKeys] forClass:c];
150+
[self setPropertyKeys:@[propertyKeys] forClass:c];
151151
}
152152
} else if ([originKey isKindOfClass:[NSArray class]]) {
153153
NSMutableArray *keyses = [NSMutableArray array];
@@ -158,13 +158,13 @@ - (void)setOriginKey:(id)originKey forClass:(Class)c
158158
}
159159
}
160160
if (keyses.count) {
161-
[self setPorpertyKeys:keyses forClass:c];
161+
[self setPropertyKeys:keyses forClass:c];
162162
}
163163
}
164164
}
165165

166166
/** 对应着字典中的多级key */
167-
- (void)setPorpertyKeys:(NSArray *)propertyKeys forClass:(Class)c
167+
- (void)setPropertyKeys:(NSArray *)propertyKeys forClass:(Class)c
168168
{
169169
if (propertyKeys.count == 0) return;
170170
NSString *key = NSStringFromClass(c);

MJExtension/NSObject+MJProperty.m

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -140,35 +140,32 @@ + (NSMutableArray *)mj_properties
140140
{
141141
NSMutableArray *cachedProperties = [self mj_propertyDictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)];
142142
if (cachedProperties == nil) {
143-
144-
if (cachedProperties == nil) {
145-
cachedProperties = [NSMutableArray array];
143+
cachedProperties = [NSMutableArray array];
144+
145+
[self mj_enumerateClasses:^(__unsafe_unretained Class c, BOOL *stop) {
146+
// 1.获得所有的成员变量
147+
unsigned int outCount = 0;
148+
objc_property_t *properties = class_copyPropertyList(c, &outCount);
146149

147-
[self mj_enumerateClasses:^(__unsafe_unretained Class c, BOOL *stop) {
148-
// 1.获得所有的成员变量
149-
unsigned int outCount = 0;
150-
objc_property_t *properties = class_copyPropertyList(c, &outCount);
151-
152-
// 2.遍历每一个成员变量
153-
for (unsigned int i = 0; i<outCount; i++) {
154-
MJProperty *property = [MJProperty cachedPropertyWithProperty:properties[i]];
155-
// 过滤掉Foundation框架类里面的属性
156-
if ([MJFoundation isClassFromFoundation:property.srcClass]) continue;
157-
// 过滤掉`hash`, `superclass`, `description`, `debugDescription`
158-
if ([MJFoundation isFromNSObjectProtocolProperty:property.name]) continue;
159-
160-
property.srcClass = c;
161-
[property setOriginKey:[self mj_propertyKey:property.name] forClass:self];
162-
[property setObjectClassInArray:[self mj_propertyObjectClassInArray:property.name] forClass:self];
163-
[cachedProperties addObject:property];
164-
}
150+
// 2.遍历每一个成员变量
151+
for (unsigned int i = 0; i<outCount; i++) {
152+
MJProperty *property = [MJProperty cachedPropertyWithProperty:properties[i]];
153+
// 过滤掉Foundation框架类里面的属性
154+
if ([MJFoundation isClassFromFoundation:property.srcClass]) continue;
155+
// 过滤掉`hash`, `superclass`, `description`, `debugDescription`
156+
if ([MJFoundation isFromNSObjectProtocolProperty:property.name]) continue;
165157

166-
// 3.释放内存
167-
free(properties);
168-
}];
158+
property.srcClass = c;
159+
[property setOriginKey:[self mj_propertyKey:property.name] forClass:self];
160+
[property setObjectClassInArray:[self mj_propertyObjectClassInArray:property.name] forClass:self];
161+
[cachedProperties addObject:property];
162+
}
169163

170-
[self mj_propertyDictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)] = cachedProperties;
171-
}
164+
// 3.释放内存
165+
free(properties);
166+
}];
167+
168+
[self mj_propertyDictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)] = cachedProperties;
172169
}
173170

174171
return cachedProperties;

0 commit comments

Comments
 (0)