forked from illusionspaces/WKJavaScriptBridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSHRMMsgCommand.m
More file actions
executable file
·61 lines (53 loc) · 1.68 KB
/
Copy pathSHRMMsgCommand.m
File metadata and controls
executable file
·61 lines (53 loc) · 1.68 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
52
53
54
55
56
57
58
59
60
61
//
// SHRMMsgCommand.m
// Hybrid-framework
//
// Created by 王凯 on 2018/12/7.
// Copyright © 2018 王凯. All rights reserved.
//
#import "SHRMMsgCommand.h"
@interface SHRMMsgCommand ()
@property (nonatomic, readwrite) NSArray* arguments;
@property (nonatomic, readwrite) NSString* callbackId;
@property (nonatomic, readwrite) NSString* className;
@property (nonatomic, readwrite) NSString* methodName;
@end
@implementation SHRMMsgCommand
+ (SHRMMsgCommand *)commandFromJson:(NSArray*)jsonEntry {
return [[SHRMMsgCommand alloc] initFromJson:jsonEntry];
}
- (id)initFromJson:(NSArray*)jsonEntry {
id tmp = [jsonEntry objectAtIndex:0];
NSString* callbackId = tmp == [NSNull null] ? nil : tmp;
NSString* className = [jsonEntry objectAtIndex:1];
NSString* methodName = [jsonEntry objectAtIndex:2];
NSMutableArray* arguments = [jsonEntry objectAtIndex:3];
return [self initWithArguments:arguments
callbackId:callbackId
className:className
methodName:methodName];
}
- (id)initWithArguments:(NSArray*)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;
}
- (id)argumentAtIndex:(NSUInteger)index {
if (index >= [_arguments count]) {
return nil;
}
id argument = [_arguments objectAtIndex:index];
if (argument == [NSNull null]) {
argument = nil;
}
return argument;
}
@end