-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathWKMsgCommand.m
More file actions
executable file
·51 lines (43 loc) · 1.49 KB
/
WKMsgCommand.m
File metadata and controls
executable file
·51 lines (43 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// WKMsgCommand.m
// Hybrid-framework
//
// Created by 王凯 on 2018/12/7.
// Copyright © 2018 王凯. All rights reserved.
//
#import "WKMsgCommand.h"
@interface WKMsgCommand ()
@property (nonatomic, readwrite) NSDictionary* arguments;
@property (nonatomic, readwrite) NSString* callbackId;
@property (nonatomic, readwrite) NSString* className;
@property (nonatomic, readwrite) NSString* methodName;
@end
@implementation WKMsgCommand
+ (WKMsgCommand *)commandFromJson:(NSDictionary *)jsonEntry {
return [[WKMsgCommand alloc] initFromJson:jsonEntry];
}
- (id)initFromJson:(NSDictionary *)jsonEntry {
id tmp = [jsonEntry objectForKey:@"callbackId"];
NSString *callbackId = tmp == [NSNull null] ? nil : tmp;
NSString *className = [jsonEntry objectForKey:@"service"];
NSString *methodName = [jsonEntry objectForKey:@"action"];
NSDictionary *arguments = [jsonEntry objectForKey:@"actionArgs"];
return [self initWithArguments:arguments
callbackId:callbackId
className:className
methodName:methodName];
}
- (id)initWithArguments:(NSDictionary *)arguments
callbackId:(NSString *)callbackId
className:(NSString *)className
methodName:(NSString *)methodName {
self = [super init];
if (self != nil) {
_arguments = arguments;
_callbackId = callbackId;
_className = className;
_methodName = methodName;
}
return self;
}
@end