iOS:Native plugin use safe method to get from dictionary,avoid type error

This commit is contained in:
pengfeizhou
2021-02-01 18:10:11 +08:00
committed by osborn
parent 156f70bb97
commit fe4e90ec53
11 changed files with 91 additions and 88 deletions

View File

@@ -32,8 +32,8 @@ - (void)show:(NSDictionary *)params withPromise:(DoricPromise *)promise {
}
[superView bringSubviewToFront:self.fullScreenView];
self.fullScreenView.hidden = NO;
NSString *viewId = params[@"id"];
NSString *type = params[@"type"];
NSString *viewId = [params optString:@"id"];
NSString *type = [params optString:@"type"];
DoricViewNode *viewNode = [self.doricContext targetViewNode:viewId];
if (!viewNode) {
viewNode = [[DoricViewNode create:self.doricContext withType:type] also:^(DoricViewNode *it) {
@@ -51,14 +51,14 @@ - (void)show:(NSDictionary *)params withPromise:(DoricPromise *)promise {
}
}];
}
[viewNode blend:params[@"props"]];
[viewNode blend:[params optObject:@"props"]];
[self.fullScreenView.doricLayout apply];
[promise resolve:nil];
}];
}
- (void)dismiss:(NSDictionary *)params withPromise:(DoricPromise *)promise {
NSString *viewId = params[@"id"];
NSString *viewId = [params optString:@"id"];
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;