Skip to content

Commit 767a07d

Browse files
author
Dario Segura
committed
-[README] Added examples to the read me.
1 parent 881f1c1 commit 767a07d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
# About this fork
22

3-
The goal is to bring the new Objective-C to Javascript bridge to be featured in iOS 7 to iOS 5 and 6. That means that the same code will transition seamlessly to iOS 7 when the time to drop older iOS version comes.
3+
The goal is to bring the new Objective-C to Javascript bridge to be featured in iOS 7 to iOS 5 and 6. That means that the same code will transition seamlessly to iOS 7 when the time to drop older iOS versions comes.
44
Some refactoring was involved but nothing major mostly just making sure the project doesn't use undocumented frameworks/functions.
55

6+
Some good examples on how to use it here:
7+
http://www.steamclock.com/blog/2013/05/apple-objective-c-javascript-bridge/
8+
9+
The most basic example:
10+
@protocol NativeObjectExport <JSExport>
11+
-(void)log:(NSString*)string;
12+
@end
13+
14+
@interface NativeObject : NSObject <NativeObjectExport>
15+
@end
16+
17+
@implementation NativeObject
18+
19+
-(void)log:(NSString*)string {
20+
NSLog(@"js: %@", string);
21+
}
22+
23+
@end
24+
25+
JSContext* context = [[JSContext alloc] init];
26+
context[@"nativeObject"] = [[NativeObject alloc] init];
27+
[context evaluateScript:@"nativeObject.log(\"Hello Javascript\")"];
28+
29+
30+
631
A pull request was submitted to merge this into the main repo.
732

833
Thanks!

0 commit comments

Comments
 (0)