Skip to content

Commit 866db85

Browse files
authored
Merge pull request #656 from kinarob/Fix_properties_thread_safe_issue
Fix `properties` thread safe issue
2 parents 9c4f7f2 + 9896e66 commit 866db85

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

MJExtension/NSObject+MJProperty.m

+4-7
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ + (Class)propertyObjectClassInArray:(NSString *)propertyName
135135
+ (void)mj_enumerateProperties:(MJPropertiesEnumeration)enumeration
136136
{
137137
// 获得成员变量
138+
MJExtensionSemaphoreCreate
139+
MJExtensionSemaphoreWait
138140
NSArray *cachedProperties = [self properties];
139-
141+
MJExtensionSemaphoreSignal
140142
// 遍历成员变量
141143
BOOL stop = NO;
142144
for (MJProperty *property in cachedProperties) {
@@ -149,11 +151,8 @@ + (void)mj_enumerateProperties:(MJPropertiesEnumeration)enumeration
149151
+ (NSMutableArray *)properties
150152
{
151153
NSMutableArray *cachedProperties = [self propertyDictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)];
152-
153154
if (cachedProperties == nil) {
154-
MJExtensionSemaphoreCreate
155-
MJExtensionSemaphoreWait
156-
155+
157156
if (cachedProperties == nil) {
158157
cachedProperties = [NSMutableArray array];
159158

@@ -179,8 +178,6 @@ + (NSMutableArray *)properties
179178

180179
[self propertyDictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)] = cachedProperties;
181180
}
182-
183-
MJExtensionSemaphoreSignal
184181
}
185182

186183
return cachedProperties;

0 commit comments

Comments
 (0)