Skip to content

Commit cd4748b

Browse files
authored
Merge pull request #797 from CoderMJLee/revert-789-fix-config-with-super-class-property-bug
Revert "Fix config with inherited property bug"
2 parents c82358c + 2572370 commit cd4748b

File tree

5 files changed

+13
-86
lines changed

5 files changed

+13
-86
lines changed

MJExtension/NSObject+MJClass.m

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,33 +145,31 @@ + (void)mj_setupBlockReturnValue:(id (^)(void))block key:(const char *)key
145145
MJExtensionSemaphoreSignal
146146
}
147147

148-
+ (NSMutableArray *)mj_totalObjectsWithSelector:(SEL)selector key:(const char *)key {
148+
+ (NSMutableArray *)mj_totalObjectsWithSelector:(SEL)selector key:(const char *)key
149+
{
149150
MJExtensionSemaphoreCreate
150151
MJExtensionSemaphoreWait
151152
NSMutableArray *array = [self mj_classDictForKey:key][NSStringFromClass(self)];
152153
if (array == nil) {
153154
// 创建、存储
154155
[self mj_classDictForKey:key][NSStringFromClass(self)] = array = [NSMutableArray array];
155-
NSMutableSet *classMethodSets = NSMutableSet.set;
156-
[self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) {
157-
Method method = class_getClassMethod(c, selector);
158-
NSNumber *methodAddress = @((int64_t)(void *)method);
159-
if (method && ![classMethodSets containsObject:methodAddress]) {
156+
157+
if ([self respondsToSelector:selector]) {
160158
#pragma clang diagnostic push
161159
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
162-
NSArray *subArray = [c performSelector:selector];
160+
NSArray *subArray = [self performSelector:selector];
163161
#pragma clang diagnostic pop
164-
if (subArray) {
165-
[array addObjectsFromArray:subArray];
166-
}
167-
[classMethodSets addObject:methodAddress];
162+
if (subArray) {
163+
[array addObjectsFromArray:subArray];
168164
}
165+
}
166+
167+
[self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) {
169168
NSArray *subArray = objc_getAssociatedObject(c, key);
170169
[array addObjectsFromArray:subArray];
171170
}];
172171
}
173172
MJExtensionSemaphoreSignal
174173
return array;
175174
}
176-
177175
@end

MJExtensionDemo.xcodeproj/project.pbxproj

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
2D2DBA832317DBE0005A689E /* MJAd.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D2DBA732317DBDF005A689E /* MJAd.m */; };
5454
2D2DBA842317DBE0005A689E /* MJExtensionConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D2DBA752317DBDF005A689E /* MJExtensionConfig.m */; };
5555
2D2DBA852317DBE0005A689E /* MJPerson.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D2DBA772317DBDF005A689E /* MJPerson.m */; };
56-
6B431A1D253F2EA900F08763 /* MJElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B431A1C253F2EA900F08763 /* MJElement.m */; };
5756
/* End PBXBuildFile section */
5857

5958
/* Begin PBXContainerItemProxy section */
@@ -156,8 +155,6 @@
156155
2D2DBA762317DBDF005A689E /* MJBook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJBook.h; sourceTree = "<group>"; };
157156
2D2DBA772317DBDF005A689E /* MJPerson.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MJPerson.m; sourceTree = "<group>"; };
158157
2D2DBA872317DCCF005A689E /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = "<group>"; };
159-
6B431A1B253F2EA900F08763 /* MJElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MJElement.h; sourceTree = "<group>"; };
160-
6B431A1C253F2EA900F08763 /* MJElement.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MJElement.m; sourceTree = "<group>"; };
161158
/* End PBXFileReference section */
162159

163160
/* Begin PBXFrameworksBuildPhase section */
@@ -292,20 +289,18 @@
292289
2D2DBA602317DBDF005A689E /* MJDog.m */,
293290
2D2DBA6B2317DBDF005A689E /* MJExtensionConfig.h */,
294291
2D2DBA752317DBDF005A689E /* MJExtensionConfig.m */,
295-
0130EE7E233C56D8008D2386 /* MJFrenchUser.h */,
296-
0130EE7F233C56D8008D2386 /* MJFrenchUser.m */,
297292
2D2DBA682317DBDF005A689E /* MJPerson.h */,
298293
2D2DBA772317DBDF005A689E /* MJPerson.m */,
299294
2D2DBA622317DBDF005A689E /* MJStatus.h */,
300295
2D2DBA722317DBDF005A689E /* MJStatus.m */,
301296
2D2DBA642317DBDF005A689E /* MJStatusResult.h */,
302297
2D2DBA712317DBDF005A689E /* MJStatusResult.m */,
303-
2D2DBA6F2317DBDF005A689E /* MJStudent.h */,
304298
2D2DBA662317DBDF005A689E /* MJStudent.m */,
299+
2D2DBA6F2317DBDF005A689E /* MJStudent.h */,
305300
2D2DBA672317DBDF005A689E /* MJUser.h */,
306301
2D2DBA6E2317DBDF005A689E /* MJUser.m */,
307-
6B431A1B253F2EA900F08763 /* MJElement.h */,
308-
6B431A1C253F2EA900F08763 /* MJElement.m */,
302+
0130EE7E233C56D8008D2386 /* MJFrenchUser.h */,
303+
0130EE7F233C56D8008D2386 /* MJFrenchUser.m */,
309304
);
310305
path = Model;
311306
sourceTree = "<group>";
@@ -506,7 +501,6 @@
506501
2D2DBA842317DBE0005A689E /* MJExtensionConfig.m in Sources */,
507502
2D2DBA7F2317DBE0005A689E /* MJBaseObject.m in Sources */,
508503
2D2DBA7D2317DBE0005A689E /* MJBook.m in Sources */,
509-
6B431A1D253F2EA900F08763 /* MJElement.m in Sources */,
510504
2D2DBA7A2317DBE0005A689E /* MJDog.m in Sources */,
511505
);
512506
runOnlyForDeploymentPostprocessing = 0;

MJExtensionTests/MJExtensionTests.m

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#import <CoreData/CoreData.h>
2020
#import "MJFrenchUser.h"
2121
#import "MJCat.h"
22-
#import "MJElement.h"
2322

2423
@interface MJExtensionTests : XCTestCase
2524

@@ -526,16 +525,4 @@ - (void)testLogAllProperties {
526525

527526
MJExtensionLog(@"%@", user);
528527
}
529-
530-
#pragma mark 使用 mj_ignoredPropertyNames/mj_allowedPropertyNames 存在继承
531-
- (void)testIgnoredInheritedProperties {
532-
NSDictionary *dict = @{
533-
@"count" : @"100",
534-
@"renderName" : @"MJRenderElementName"
535-
};
536-
MJRenderElement *renderElement = [MJRenderElement mj_objectWithKeyValues:dict];
537-
XCTAssert(renderElement.count == 0);
538-
XCTAssertFalse(renderElement.renderName);
539-
}
540-
541528
@end

MJExtensionTests/Model/MJElement.h

Lines changed: 0 additions & 26 deletions
This file was deleted.

MJExtensionTests/Model/MJElement.m

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)