@@ -27,20 +27,20 @@ JSContext *context = [JSBScriptingSupport globalContext];
2727];
2828```
2929
30- Retrieve the ` JSContext ` instance from ` JSBScriptingSupport ` .
30+ 1 . Retrieve the ` JSContext ` instance from ` JSBScriptingSupport ` .
3131The context includes a lot of system classes that has been ` JSExports ` adopted.
3232``` objc
3333JSContext *context = [JSBScriptingSupport globalContext ];
3434```
3535
36- Add ` JSExports ` adopted classes each framework if needed.
36+ 2 . Add ` JSExports ` adopted classes each framework if needed.
3737By default, ` Foundation ` , ` UIKit ` , ` QuartzCore ` frameworks are included.
3838``` objc
3939[context addScriptingSupport: @"MapKit"] ;
4040[ context addScriptingSupport:@"MessageUI"] ;
4141```
4242
43- It is ready to use, writing appliction code and evaluate in JavaScript.
43+ 3. It is ready to use, writing appliction code and evaluate in JavaScript.
4444```
4545[ context evaluateScript:
4646 @"var window = UIWindow.new();"
@@ -181,6 +181,27 @@ See the [UICatalog](https://github.com/kishikawakatsumi/JavaScriptBridge/tree/ma
181181You can define custom class in JavaScript.
182182It is needs to interact system provided framework.
183183
184+ `JSB.define(declaration, instanceMembers)` function defines Objective-C class in JavaScript.
185+ Pass the class declaration string to first argument.
186+
187+ Second argument is instance method definitions as hash.
188+ The hash object inclueds function object, each keys are to be used as method name.
189+
190+ **Example**
191+
192+ ```javascript
193+ var MainViewController = JSB.define('MainViewController : UITableViewController', {
194+ viewDidLoad: function() { // Instance Method Definitions
195+ self.navigationItem.title = 'UICatalog';
196+ },
197+ viewWillAppear: function(animated) {
198+ self.tableView.reloadData();
199+ }
200+ });
201+ ```
202+
203+ ** Example**
204+
184205``` javascript
185206var MainViewController = JSB .define (' MainViewController : UITableViewController <UITableviewDataSource, UITableviewDelegate>' , // Declaration
186207// Instance Method Definitions
@@ -209,6 +230,9 @@ var MainViewController = JSB.define('MainViewController : UITableViewController
209230###Modules
210231
211232JavaScriptBridge provides simple module system ` require/exports ` funcitons, like Node.js.
233+
234+ ` JSB.require(name) ` function enables external module, ` JSB.exports ` publishes a module.
235+
212236See [ example] ( https://github.com/kishikawakatsumi/JavaScriptBridge/tree/master/Examples/UICatalog/UICatalog/js ) .
213237
214238``` javascript
0 commit comments