UNPKG

1.16 kBPlain TextView Raw
1//
2// NSObject+RNBranch.m
3// RNBranch
4//
5// Created by Jimmy Dee on 1/26/17.
6// Copyright © 2017 Branch Metrics. All rights reserved.
7//
8
9#import <React/RCTLog.h>
10
11#import "NSObject+RNBranch.h"
12#import "RNBranchProperty.h"
13
14@implementation NSObject(RNBranch)
15
16+ (NSDictionary<NSString *,RNBranchProperty *> *)supportedProperties
17{
18 return @{};
19}
20
21- (void)setSupportedPropertiesWithMap:(NSDictionary *)map
22{
23 for (NSString *key in map.allKeys) {
24 RNBranchProperty *property = self.class.supportedProperties[key];
25 if (!property) {
26 RCTLogWarn(@"\"%@\" is not a supported property for %@.", key, NSStringFromClass(self.class));
27 continue;
28 }
29
30 id value = map[key];
31 Class type = property.type;
32 if (![value isKindOfClass:type]) {
33 RCTLogWarn(@"\"%@\" requires a value of type %@.", key, NSStringFromClass(type));
34 continue;
35 }
36
37#pragma clang diagnostic push
38#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
39 [self performSelector:property.setterSelector withObject:value];
40#pragma clang diagnostic pop
41 }
42}
43
44@end