Skip to content

Commit 0944db6

Browse files
Update README.md
1 parent 5a3a419 commit 0944db6

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,23 @@ JSContext *context = [JSBScriptingSupport globalContext];
3737
```
3838

3939
1. Retrieve the `JSContext` instance from `JSBScriptingSupport`.
40-
The context includes a lot of system classes that has been `JSExports` adopted.
41-
```objc
40+
The context includes a lot of system classes that has been `JSExports` adopted.
41+
42+
```objc
4243
JSContext *context = [JSBScriptingSupport globalContext];
4344
```
4445

4546
2. Add `JSExports` adopted classes each framework if needed.
46-
By default, `Foundation`, `UIKit`, `QuartzCore` frameworks are included.
47-
```objc
47+
By default, `Foundation`, `UIKit`, `QuartzCore` frameworks are included.
48+
49+
```objc
4850
[context addScriptingSupport:@"MapKit"];
4951
[context addScriptingSupport:@"MessageUI"];
5052
```
5153
5254
3. It is ready to use, writing appliction code and evaluate in JavaScript.
53-
```
55+
56+
```objc
5457
[context evaluateScript:
5558
@"var window = UIWindow.new();"
5659
@"window.frame = UIScreen.mainScreen().bounds;"
@@ -59,6 +62,26 @@ By default, `Foundation`, `UIKit`, `QuartzCore` frameworks are included.
5962
];
6063
```
6164

65+
#### Manually setting up a new JSContext instance
66+
1. Create new `JSContext` instance instead using `globalContext`.
67+
You can separate JavaScript environments to use multiple contexts.
68+
69+
```objc
70+
JSContext *context = [[JSContext alloc] init];
71+
```
72+
73+
2. Add `JSExports` adopted classes each framework if needed.
74+
`Foundation`, `UIKit` and `QuartzCore` frameworks MUST be added.
75+
76+
```objc
77+
[context addScriptingSupport:@"Foundation"];
78+
[context addScriptingSupport:@"UIKit"];
79+
[context addScriptingSupport:@"QuartzCore"];
80+
[context addScriptingSupport:@"Accounts"];
81+
[context addScriptingSupport:@"Social"];
82+
```
83+
84+
6285
### Syntax / Naming conventions
6386
6487
**Class name**

0 commit comments

Comments
 (0)