Skip to content

Commit

Permalink
Merge pull request #797 from CoderMJLee/revert-789-fix-config-with-su…
Browse files Browse the repository at this point in the history
…per-class-property-bug

Revert "Fix config with inherited property bug"
  • Loading branch information
kinarobin authored Nov 18, 2020
2 parents c82358c + 2572370 commit cd4748b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 86 deletions.
22 changes: 10 additions & 12 deletions MJExtension/NSObject+MJClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,33 +145,31 @@ + (void)mj_setupBlockReturnValue:(id (^)(void))block key:(const char *)key
MJExtensionSemaphoreSignal
}

+ (NSMutableArray *)mj_totalObjectsWithSelector:(SEL)selector key:(const char *)key {
+ (NSMutableArray *)mj_totalObjectsWithSelector:(SEL)selector key:(const char *)key
{
MJExtensionSemaphoreCreate
MJExtensionSemaphoreWait
NSMutableArray *array = [self mj_classDictForKey:key][NSStringFromClass(self)];
if (array == nil) {
// 创建、存储
[self mj_classDictForKey:key][NSStringFromClass(self)] = array = [NSMutableArray array];
NSMutableSet *classMethodSets = NSMutableSet.set;
[self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) {
Method method = class_getClassMethod(c, selector);
NSNumber *methodAddress = @((int64_t)(void *)method);
if (method && ![classMethodSets containsObject:methodAddress]) {

if ([self respondsToSelector:selector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
NSArray *subArray = [c performSelector:selector];
NSArray *subArray = [self performSelector:selector];
#pragma clang diagnostic pop
if (subArray) {
[array addObjectsFromArray:subArray];
}
[classMethodSets addObject:methodAddress];
if (subArray) {
[array addObjectsFromArray:subArray];
}
}

[self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) {
NSArray *subArray = objc_getAssociatedObject(c, key);
[array addObjectsFromArray:subArray];
}];
}
MJExtensionSemaphoreSignal
return array;
}

@end
12 changes: 3 additions & 9 deletions MJExtensionDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
2D2DBA832317DBE0005A689E /* MJAd.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D2DBA732317DBDF005A689E /* MJAd.m */; };
2D2DBA842317DBE0005A689E /* MJExtensionConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D2DBA752317DBDF005A689E /* MJExtensionConfig.m */; };
2D2DBA852317DBE0005A689E /* MJPerson.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D2DBA772317DBDF005A689E /* MJPerson.m */; };
6B431A1D253F2EA900F08763 /* MJElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B431A1C253F2EA900F08763 /* MJElement.m */; };
/* End PBXBuildFile section */

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

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -292,20 +289,18 @@
2D2DBA602317DBDF005A689E /* MJDog.m */,
2D2DBA6B2317DBDF005A689E /* MJExtensionConfig.h */,
2D2DBA752317DBDF005A689E /* MJExtensionConfig.m */,
0130EE7E233C56D8008D2386 /* MJFrenchUser.h */,
0130EE7F233C56D8008D2386 /* MJFrenchUser.m */,
2D2DBA682317DBDF005A689E /* MJPerson.h */,
2D2DBA772317DBDF005A689E /* MJPerson.m */,
2D2DBA622317DBDF005A689E /* MJStatus.h */,
2D2DBA722317DBDF005A689E /* MJStatus.m */,
2D2DBA642317DBDF005A689E /* MJStatusResult.h */,
2D2DBA712317DBDF005A689E /* MJStatusResult.m */,
2D2DBA6F2317DBDF005A689E /* MJStudent.h */,
2D2DBA662317DBDF005A689E /* MJStudent.m */,
2D2DBA6F2317DBDF005A689E /* MJStudent.h */,
2D2DBA672317DBDF005A689E /* MJUser.h */,
2D2DBA6E2317DBDF005A689E /* MJUser.m */,
6B431A1B253F2EA900F08763 /* MJElement.h */,
6B431A1C253F2EA900F08763 /* MJElement.m */,
0130EE7E233C56D8008D2386 /* MJFrenchUser.h */,
0130EE7F233C56D8008D2386 /* MJFrenchUser.m */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -506,7 +501,6 @@
2D2DBA842317DBE0005A689E /* MJExtensionConfig.m in Sources */,
2D2DBA7F2317DBE0005A689E /* MJBaseObject.m in Sources */,
2D2DBA7D2317DBE0005A689E /* MJBook.m in Sources */,
6B431A1D253F2EA900F08763 /* MJElement.m in Sources */,
2D2DBA7A2317DBE0005A689E /* MJDog.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
13 changes: 0 additions & 13 deletions MJExtensionTests/MJExtensionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import <CoreData/CoreData.h>
#import "MJFrenchUser.h"
#import "MJCat.h"
#import "MJElement.h"

@interface MJExtensionTests : XCTestCase

Expand Down Expand Up @@ -526,16 +525,4 @@ - (void)testLogAllProperties {

MJExtensionLog(@"%@", user);
}

#pragma mark 使用 mj_ignoredPropertyNames/mj_allowedPropertyNames 存在继承
- (void)testIgnoredInheritedProperties {
NSDictionary *dict = @{
@"count" : @"100",
@"renderName" : @"MJRenderElementName"
};
MJRenderElement *renderElement = [MJRenderElement mj_objectWithKeyValues:dict];
XCTAssert(renderElement.count == 0);
XCTAssertFalse(renderElement.renderName);
}

@end
26 changes: 0 additions & 26 deletions MJExtensionTests/Model/MJElement.h

This file was deleted.

26 changes: 0 additions & 26 deletions MJExtensionTests/Model/MJElement.m

This file was deleted.

0 comments on commit cd4748b

Please sign in to comment.