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

@ -17,8 +17,10 @@
// Created by pengfei.zhou on 2019/11/29.
//
#import <DoricCore/Doric.h>
#import "DoricAnimatePlugin.h"
#import "DoricRootNode.h"
#import "DoricExtensions.h"
@implementation DoricAnimatePlugin
@ -27,20 +29,21 @@ - (void)submit:(NSDictionary *)args withPromise:(DoricPromise *)promise {
}
- (void)animateRender:(NSDictionary *)args withPromise:(DoricPromise *)promise {
NSNumber *duration = args[@"duration"];
NSNumber *duration = [args optNumber:@"duration"];
NSString *viewId = [args optString:@"id"];
NSDictionary *props = [args optObject:@"props"];
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
NSString *viewId = args[@"id"];
[UIView animateWithDuration:[duration floatValue] / 1000
animations:^{
if (self.doricContext.rootNode.viewId == nil) {
self.doricContext.rootNode.viewId = viewId;
[self.doricContext.rootNode blend:args[@"props"]];
[self.doricContext.rootNode blend:props];
[self.doricContext.rootNode requestLayout];
} else {
DoricViewNode *viewNode = [self.doricContext targetViewNode:viewId];
[viewNode blend:args[@"props"]];
[viewNode blend:props];
[viewNode requestLayout];
}
}

View File

@ -17,11 +17,13 @@
// Created by pengfei.zhou on 2020/2/13.
//
#import <DoricCore/Doric.h>
#import "DoricCoordinatorPlugin.h"
#import "DoricSuperNode.h"
#import "DoricScrollableProtocol.h"
#import "DoricUtil.h"
#import "DoricRootNode.h"
#import "DoricExtensions.h"
@implementation DoricCoordinatorPlugin
@ -29,7 +31,7 @@ - (void)verticalScrolling:(NSDictionary *)params withPromise:(DoricPromise *)pro
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
NSArray <NSString *> *scrollableIds = params[@"scrollable"];
NSArray <NSString *> *scrollableIds = [params optArray:@"scrollable"];
DoricViewNode *scrollNode = nil;
for (NSString *value in scrollableIds) {
if (!scrollNode) {
@ -44,9 +46,9 @@ - (void)verticalScrolling:(NSDictionary *)params withPromise:(DoricPromise *)pro
[promise reject:@"Cannot find scrollable view"];
return;
}
NSDictionary *scrollRange = params[@"scrollRange"];
CGFloat startAnchor = [scrollRange[@"start"] floatValue];
CGFloat endAnchor = [scrollRange[@"end"] floatValue];
NSDictionary *scrollRange = [params optObject:@"scrollRange"];
CGFloat startAnchor = [[scrollRange optNumber:@"start"] floatValue];
CGFloat endAnchor = [[scrollRange optNumber:@"end"] floatValue];
id target = params[@"target"];
BOOL isNavBar = false;
DoricViewNode *targetNode = nil;
@ -66,10 +68,10 @@ - (void)verticalScrolling:(NSDictionary *)params withPromise:(DoricPromise *)pro
[promise reject:@"Cannot find target view"];
}
}
NSDictionary *changing = params[@"changing"];
NSString *name = changing[@"name"];
NSNumber *changingStart = changing[@"start"];
NSNumber *changingEnd = changing[@"end"];
NSDictionary *changing = [params optObject:@"changing"];
NSString *name = [changing optString:@"name"];
NSNumber *changingStart = [changing optNumber:@"start"];
NSNumber *changingEnd = [changing optNumber:@"end"];
if ([scrollNode conformsToProtocol:@protocol(DoricScrollableProtocol)]) {
__weak typeof(self) __self = self;
[(id <DoricScrollableProtocol>) scrollNode addDidScrollBlock:^(UIScrollView *scrollView) {

View File

@ -31,13 +31,13 @@ - (void)toast:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
__block DoricGravity gravity = DoricGravityBottom;
[dic[@"gravity"] also:^(NSNumber *it) {
[[dic optNumber:@"gravity"] also:^(NSNumber *it) {
gravity = (DoricGravity) [it integerValue];
}];
if (self.doricContext.vc) {
ShowToastInVC(self.doricContext.vc, dic[@"msg"], gravity);
ShowToastInVC(self.doricContext.vc, [dic optString:@"msg"], gravity);
} else {
ShowToast(dic[@"msg"], gravity);
ShowToast([dic optString:@"msg"], gravity);
}
}];
}
@ -46,10 +46,10 @@ - (void)alert:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
UIAlertController *alert = [UIAlertController alertControllerWithTitle:dic[@"title"]
message:dic[@"msg"]
UIAlertController *alert = [UIAlertController alertControllerWithTitle:[dic optString:@"title"]
message:[dic optString:@"msg"]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:dic[@"okLabel"] ?: NSLocalizedString(@"OK", nil)
UIAlertAction *action = [UIAlertAction actionWithTitle:[dic optString:@"okLabel"] ?: NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[promise resolve:nil];
@ -63,18 +63,18 @@ - (void)confirm:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
UIAlertController *alert = [UIAlertController alertControllerWithTitle:dic[@"title"]
message:dic[@"msg"]
UIAlertController *alert = [UIAlertController alertControllerWithTitle:[dic optString:@"title"]
message:[dic optString:@"msg"]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:dic[@"cancelLabel"] ?: NSLocalizedString(@"Cancel", nil)
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:[dic optString:@"cancelLabel"] ?: NSLocalizedString(@"Cancel", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[promise reject:nil];
}];
[alert addAction:cancelAction];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:dic[@"okLabel"] ?: NSLocalizedString(@"Ok", nil)
UIAlertAction *okAction = [UIAlertAction actionWithTitle:[dic optString:@"okLabel"] ?: NSLocalizedString(@"Ok", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[promise resolve:nil];
@ -89,11 +89,11 @@ - (void)prompt:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
UIAlertController *alert = [UIAlertController alertControllerWithTitle:dic[@"title"]
message:dic[@"msg"]
UIAlertController *alert = [UIAlertController alertControllerWithTitle:[dic optString:@"title"]
message:[dic optString:@"msg"]
preferredStyle:UIAlertControllerStyleAlert];
NSString *placeholder = dic[@"defaultText"];
NSString *preText = dic[@"text"];
NSString *placeholder = [dic optString:@"defaultText"];
NSString *preText = [dic optString:@"text"];
[alert addTextFieldWithConfigurationHandler:^(UITextField *_Nonnull textField) {
if (placeholder.length > 0) {
textField.placeholder = placeholder;
@ -104,7 +104,7 @@ - (void)prompt:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
}];
__weak typeof(alert) _alert = alert;
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:dic[@"cancelLabel"] ?: NSLocalizedString(@"Cancel", nil)
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:[dic optString:@"cancelLabel"] ?: NSLocalizedString(@"Cancel", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
__strong typeof(_alert) alert = _alert;
@ -112,7 +112,7 @@ - (void)prompt:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
}];
[alert addAction:cancelAction];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:dic[@"okLabel"] ?: NSLocalizedString(@"Ok", nil)
UIAlertAction *okAction = [UIAlertAction actionWithTitle:[dic optString:@"okLabel"] ?: NSLocalizedString(@"Ok", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
__strong typeof(_alert) alert = _alert;

View File

@ -45,7 +45,7 @@ - (void)setHidden:(NSDictionary *)param withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
[self.doricContext.navBar doric_navBar_setHidden:[param[@"hidden"] boolValue]];
[self.doricContext.navBar doric_navBar_setHidden:[param optBool:@"hidden"]];
[promise resolve:nil];
}];
} else {
@ -58,7 +58,7 @@ - (void)setTitle:(NSDictionary *)param withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
[self.doricContext.navBar doric_navBar_setTitle:param[@"title"]];
[self.doricContext.navBar doric_navBar_setTitle:[param optString:@"title"]];
[promise resolve:nil];
}];
} else {
@ -71,7 +71,7 @@ - (void)setBgColor:(NSDictionary *)param withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
UIColor *color = DoricColor(param[@"color"]);
UIColor *color = DoricColor([param optNumber:@"color"]);
[self.doricContext.navBar doric_navBar_setBackgroundColor:color];
[promise resolve:nil];
}];
@ -85,8 +85,8 @@ - (void)setLeft:(NSDictionary *)params withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
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) {
@ -103,7 +103,7 @@ - (void)setLeft:(NSDictionary *)params withPromise:(DoricPromise *)promise {
}
}];
}
[viewNode blend:params[@"props"]];
[viewNode blend:[params optObject:@"props"]];
[self.doricContext.navBar doric_navBar_setLeft:viewNode.view];
[promise resolve:nil];
}];
@ -117,8 +117,8 @@ - (void)setRight:(NSDictionary *)params withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
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) {
@ -135,7 +135,7 @@ - (void)setRight:(NSDictionary *)params withPromise:(DoricPromise *)promise {
}
}];
}
[viewNode blend:params[@"props"]];
[viewNode blend:[params optObject:@"props"]];
[self.doricContext.navBar doric_navBar_setRight:viewNode.view];
[promise resolve:nil];
}];
@ -149,8 +149,8 @@ - (void)setCenter:(NSDictionary *)params withPromise:(DoricPromise *)promise {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
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) {
@ -167,7 +167,7 @@ - (void)setCenter:(NSDictionary *)params withPromise:(DoricPromise *)promise {
}
}];
}
[viewNode blend:params[@"props"]];
[viewNode blend:[params optObject:@"props"]];
[self.doricContext.navBar doric_navBar_setCenter:viewNode.view];
[promise resolve:nil];
}];

View File

@ -17,8 +17,9 @@
// Created by pengfei.zhou on 2019/11/23.
//
#import <DoricCore/Doric.h>
#import "DoricNavigatorPlugin.h"
#import "DoricExtensions.h"
@implementation DoricNavigatorPlugin
- (void)push:(NSDictionary *)params {
@ -26,17 +27,12 @@ - (void)push:(NSDictionary *)params {
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
BOOL animated = YES;
NSString *source = params[@"source"];
NSString *source = [params optString:@"source"];
NSString *alias = source;
NSDictionary *config = params[@"config"];
NSDictionary *config = [params optObject:@"config"];
if (config) {
if (config[@"animated"]) {
animated = [config[@"animated"] boolValue];
}
if (config[@"alias"]) {
alias = config[@"alias"];
}
animated = [config optBool:@"animated" defaultValue:animated];
alias = [config optString:@"alias" defaultValue:source];
}
[self.doricContext.navigator doric_navigator_push:source alias:alias animated:animated extra:config[@"extra"]];
}];
@ -46,10 +42,7 @@ - (void)pop:(NSDictionary *)params {
__weak typeof(self) _self = self;
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
BOOL animated = YES;
if (params[@"animated"]) {
animated = [params[@"animated"] boolValue];
}
BOOL animated = [params optBool:@"animated" defaultValue:YES];
[self.doricContext.navigator doric_navigator_pop:animated];
}];
}

View File

@ -17,16 +17,17 @@
// Created by pengfei.zhou on 2019/11/21.
//
#import <DoricCore/Doric.h>
#import "DoricNetworkPlugin.h"
#import "DoricExtensions.h"
@implementation DoricNetworkPlugin
- (void)request:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
NSString *url = dic[@"url"];
NSString *method = dic[@"method"];
NSDictionary <NSString *, NSString *> *headers = dic[@"headers"];
NSNumber *timeout = dic[@"timeout"];
NSString *data = dic[@"data"];
NSString *url = [dic optString:@"url"];
NSString *method = [dic optString:@"method"];
NSDictionary <NSString *, NSString *> *headers = [dic optObject:@"headers"];
NSNumber *timeout = [dic optNumber:@"timeout"];
NSString *data = [dic optString:@"data"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
request.HTTPMethod = method.uppercaseString;
if (timeout) {

View File

@ -17,6 +17,8 @@
// Created by pengfei.zhou on 2020/1/8.
//
#import <DoricCore/Doric.h>
#import <DoricCore/DoricCore-umbrella.h>
#import "DoricNotificationPlugin.h"
@interface DoricNotificationPlugin ()
@ -34,12 +36,12 @@ - (NSDictionary *)observers {
}
- (void)publish:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
NSString *biz = dic[@"biz"];
NSString *name = dic[@"name"];
NSString *biz = [dic optString:@"biz"];
NSString *name = [dic optString:@"name"];
if (biz) {
name = [NSString stringWithFormat:@"__doric__%@#%@", biz, name];
}
NSString *data = dic[@"data"];
NSString *data = [dic optString:@"data"];
NSDictionary *dataDic = nil;
if (data) {
NSData *jsonData = [data dataUsingEncoding:NSUTF8StringEncoding];
@ -53,12 +55,12 @@ - (void)publish:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
}
- (void)subscribe:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
NSString *biz = dic[@"biz"];
NSString *name = dic[@"name"];
NSString *biz = [dic optString:@"biz"];
NSString *name = [dic optString:@"name"];
if (biz) {
name = [NSString stringWithFormat:@"__doric__%@#%@", biz, name];
}
NSString *callbackId = dic[@"callback"];
NSString *callbackId = [dic optString:@"callback"];
__weak typeof(self) _self = self;
id observer = [[NSNotificationCenter defaultCenter]
addObserverForName:name

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;

View File

@ -23,6 +23,7 @@
#import "DoricShaderPlugin.h"
#import "DoricRootNode.h"
#import "DoricUtil.h"
#import "DoricExtensions.h"
#import <objc/runtime.h>
@ -38,15 +39,15 @@ - (void)render:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
if (self.doricContext == nil) {
return;
}
NSString *viewId = argument[@"id"];
NSString *viewId = [argument optString:@"id"];
if (self.doricContext.rootNode.viewId == nil && [@"Root" isEqualToString:argument[@"type"]]) {
if (self.doricContext.rootNode.viewId == nil && [@"Root" isEqualToString:[argument optString:@"type"]]) {
self.doricContext.rootNode.viewId = viewId;
[self.doricContext.rootNode blend:argument[@"props"]];
[self.doricContext.rootNode blend:[argument optObject:@"props"]];
[self.doricContext.rootNode requestLayout];
} else {
DoricViewNode *viewNode = [self.doricContext targetViewNode:viewId];
[viewNode blend:argument[@"props"]];
[viewNode blend:[argument optObject:@"props"]];
[viewNode requestLayout];
}
[promise resolve:nil];
@ -60,9 +61,9 @@ - (void)command:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
if (self.doricContext == nil) {
return;
}
NSArray *viewIds = argument[@"viewIds"];
NSArray *viewIds = [argument optArray:@"viewIds"];
id args = argument[@"args"];
NSString *name = argument[@"name"];
NSString *name = [argument optString:@"name"];
DoricViewNode *viewNode = nil;
for (NSString *viewId in viewIds) {
if (!viewNode) {

View File

@ -19,7 +19,6 @@
#import "DoricStatusBarPlugin.h"
#import "DoricUtil.h"
#import "DoricViewNode.h"
#import "DoricExtensions.h"
#import "DoricViewController.h"
@ -32,7 +31,7 @@ - (void)setHidden:(NSDictionary *)param withPromise:(DoricPromise *)promise {
if (self.doricContext.navBar) {
if ([self.doricContext.navBar isKindOfClass:DoricViewController.class]) {
DoricViewController *target = ((DoricViewController *) self.doricContext.navBar);
target.statusBarHidden = [param[@"hidden"] boolValue];
target.statusBarHidden = [param optBool:@"hidden"];
[target setNeedsStatusBarAppearanceUpdate];
}
}
@ -46,7 +45,7 @@ - (void)setMode:(NSDictionary *)param withPromise:(DoricPromise *)promise {
if (self.doricContext.navBar) {
if ([self.doricContext.navBar isKindOfClass:DoricViewController.class]) {
DoricViewController *target = ((DoricViewController *) self.doricContext.navBar);
target.statusBarMode = [param[@"mode"] intValue];
target.statusBarMode = [[param optNumber:@"mode"] intValue];
[target setNeedsStatusBarAppearanceUpdate];
}
}
@ -58,7 +57,7 @@ - (void)setColor:(NSDictionary *)param withPromise:(DoricPromise *)promise {
[self.doricContext dispatchToMainQueue:^{
__strong typeof(_self) self = _self;
if (self.doricContext.navBar) {
UIColor *color = DoricColor(param[@"color"]);
UIColor *color = DoricColor([param optNumber:@"color"]);
[self.doricContext.navBar doric_navBar_setBackgroundColor:color];
}
}];

View File

@ -22,6 +22,8 @@
#if __has_include(<PINCache/PINCache.h>)
#import <PINCache/PINCache.h>
#import <DoricCore/Doric.h>
#import <DoricCore/DoricCore-umbrella.h>
#define DoricCache PINCache
@ -161,9 +163,9 @@ - (DoricCache *)getDiskCache:(NSString *)zone {
}
- (void)setItem:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
NSString *zone = argument[@"zone"];
NSString *key = argument[@"key"];
NSString *value = argument[@"value"];
NSString *zone = [argument optString:@"zone"];
NSString *key = [argument optString:@"key"];
NSString *value = [argument optString:@"value"];
DoricCache *diskCache = [self getDiskCache:zone];
[diskCache setObject:value forKey:key withBlock:^{
[promise resolve:nil];
@ -171,8 +173,8 @@ - (void)setItem:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
}
- (void)getItem:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
NSString *zone = argument[@"zone"];
NSString *key = argument[@"key"];
NSString *zone = [argument optString:@"zone"];
NSString *key = [argument optString:@"key"];
DoricCache *diskCache = [self getDiskCache:zone];
[diskCache objectForKey:key withBlock:^(NSString *_Nonnull key, id <NSCoding> _Nullable object) {
[promise resolve:object];
@ -180,8 +182,8 @@ - (void)getItem:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
}
- (void)remove:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
NSString *zone = argument[@"zone"];
NSString *key = argument[@"key"];
NSString *zone = [argument optString:@"zone"];
NSString *key = [argument optString:@"key"];
DoricCache *diskCache = [self getDiskCache:zone];
[diskCache removeObjectForKey:key withBlock:^(NSString *key) {
[promise resolve:nil];
@ -189,7 +191,7 @@ - (void)remove:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
}
- (void)clear:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
NSString *zone = argument[@"zone"];
NSString *zone = [argument optString:@"zone"];
DoricCache *diskCache = [self getDiskCache:zone];
[diskCache removeAllObjectsWithBlock:^{
[promise resolve:nil];