@@ -53,10 +53,13 @@ By default, `Foundation`, `UIKit`, `QuartzCore` frameworks are included.
5353### Syntax / Naming conventions
5454
5555** Class name**
56- - Same as Objectige-C
56+
57+ Same as Objectige-C
58+
5759
5860** Variable declaration**
59- - Get rid of ` Type ` instead use ` var `
61+
62+ Get rid of ` Type name ` instead use ` var `
6063
6164``` objc
6265UILabel *label;
@@ -67,7 +70,8 @@ var label;
6770```
6871
6972** Properties**
70- - Use dot syntax
73+
74+ Use dot syntax
7175
7276``` objc
7377UISlider *slider = [[UISlider alloc ] initWithFrame: frame] ;
@@ -88,9 +92,10 @@ slider.value = 50.0;
8892```
8993
9094** Invoking method**
91- - Use dot syntax
92- - All colons are removed from the selector
93- - Any lowercase letter that had followed a colon will be capitalized
95+
96+ Use dot syntax
97+ All colons are removed from the selector
98+ Any lowercase letter that had followed a colon will be capitalized
9499
95100``` objc
96101UIWindow *window = [[UIWindow alloc ] initWithFrame: [[ UIScreen mainScreen] bounds]] ;
@@ -101,7 +106,8 @@ var window = UIWindow.alloc().initWithFrame(UIScreen.mainScreen().bounds);
101106```
102107
103108** Struct (CGRect, NSRange, etc.)**
104- - Use Hashes
109+
110+ Use Hashes
105111
106112``` objc
107113UIView *view = [UIView new ];
@@ -122,7 +128,7 @@ var width = view.frame.width; // => 280
122128## Examples
123129###Hello world on JavaScriptBridge
124130
125- This is the most simple way.
131+ This is the most simplest way.
126132
127133``` objc
128134@implementation JSBAppDelegate
@@ -171,6 +177,26 @@ This is the most simple way.
171177@end
172178```
173179
180+ Of course, the script is able to be loaded from external file.
181+ ```objc
182+ @implementation JSBAppDelegate
183+
184+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
185+ {
186+ NSBundle *mainBundle = [NSBundle mainBundle];
187+ NSString *path = [mainBundle pathForResource:@"main" ofType:@"js"];
188+
189+ NSString *script = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
190+
191+ JSContext *context = [JSBScriptingSupport globalContext];
192+ [context evaluateScript:script];
193+
194+ return YES;
195+ }
196+
197+ @end
198+ ```
199+
174200###Writing apps with only JavaScript
175201
176202See the [ UICatalog] ( https://github.com/kishikawakatsumi/JavaScriptBridge/tree/master/Examples/UICatalog/UICatalog ) example.
0 commit comments