-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix options.animations merging - `objectProperties` function didn't return superclass properties which resulted in wrong option merging. * Rename `objectProperties` to `classProperties`. Closes #6373
- Loading branch information
Showing
6 changed files
with
83 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSObject (Utils) | ||
|
||
- (NSArray *)classProperties; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#import "NSObject+Utils.h" | ||
#import "RNNOptions.h" | ||
#import <objc/runtime.h> | ||
|
||
@implementation NSObject (Utils) | ||
|
||
- (NSArray *)classProperties { | ||
NSMutableArray* properties = [NSMutableArray new]; | ||
unsigned int count; | ||
Class cls = [self class]; | ||
do { | ||
objc_property_t* props = class_copyPropertyList(cls, &count); | ||
for (int i = 0; i < count; i++) { | ||
objc_property_t property = props[i]; | ||
NSString *propertyName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding]; | ||
[properties addObject:propertyName]; | ||
} | ||
free(props); | ||
cls = [cls superclass]; | ||
} while (![cls isEqual:[NSObject class]] && cls != nil); | ||
return properties; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#import <XCTest/XCTest.h> | ||
#import <ReactNativeNavigation/NSObject+Utils.h> | ||
#import <ReactNativeNavigation/RNNLayoutOptions.h> | ||
#import <ReactNativeNavigation/ElementTransitionOptions.h> | ||
|
||
@interface TestClass : NSObject | ||
@property (nonatomic, strong) NSString* testProperty; | ||
@end | ||
@implementation TestClass | ||
@end | ||
|
||
@interface TestSubClass : TestClass | ||
@property (nonatomic, strong) NSString* testSubProperty; | ||
@end | ||
@implementation TestSubClass | ||
@end | ||
|
||
@interface NSObjectUtilsTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation NSObjectUtilsTests | ||
|
||
- (void)testReturnClassProperties { | ||
TestClass* testObject = [TestClass new]; | ||
NSArray* properties = [testObject classProperties]; | ||
NSArray* expectedProperties = @[@"testProperty"]; | ||
XCTAssertTrue([properties isEqualToArray:expectedProperties]); | ||
} | ||
|
||
- (void)testReturnSuperClassProperties { | ||
TestSubClass* testObject = [TestSubClass new]; | ||
NSArray* properties = [testObject classProperties]; | ||
NSArray* expectedProperties = @[@"testSubProperty", @"testProperty"]; | ||
XCTAssertTrue([properties isEqualToArray:expectedProperties]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters