mirror of
https://github.com/status-im/react-native.git
synced 2025-02-22 22:28:09 +00:00
Add convert compatible of NSString for bridge message data (#24630)
Summary: Fixes https://twitter.com/estevao_lucas/status/1117572702083190785?s=215 in #24626 . Now we try to convert any id to `NSString`, not throw error. cc. cpojer . [iOS] [Fixed] - Add convert compatible of NSString for bridge message data Pull Request resolved: https://github.com/facebook/react-native/pull/24630 Differential Revision: D15120205 Pulled By: cpojer fbshipit-source-id: 4849a8e941410b292f971608a9cdb38c11502445
This commit is contained in:
parent
0a3bbcd1b2
commit
c37e9c8905
@ -53,12 +53,21 @@ RCT_NUMBER_CONVERTER(NSUInteger, unsignedIntegerValue)
|
||||
|
||||
RCT_JSON_CONVERTER(NSArray)
|
||||
RCT_JSON_CONVERTER(NSDictionary)
|
||||
RCT_JSON_CONVERTER(NSString)
|
||||
RCT_JSON_CONVERTER(NSNumber)
|
||||
|
||||
RCT_CUSTOM_CONVERTER(NSSet *, NSSet, [NSSet setWithArray:json])
|
||||
RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncoding])
|
||||
|
||||
+ (NSString *)NSString:(id)json
|
||||
{
|
||||
if ([json isKindOfClass:NSString.class]) {
|
||||
return json;
|
||||
} else if (json && json != (id)kCFNull) {
|
||||
return [NSString stringWithFormat:@"%@",json];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSIndexSet *)NSIndexSet:(id)json
|
||||
{
|
||||
json = [self NSNumberArray:json];
|
||||
|
Loading…
x
Reference in New Issue
Block a user