iOS dev HACK!     JS    ObjC linluxiang@gmail.com
HTML
HTMLJS     Objc
HTMLJS     ObjcUIWebView
JS Global
JS Global- (void)webView:(id)sender didClearWindowObject:(id)windowObject forFrame:(WebFrame*)frame {
JS Global  - (void)webView:(id)sender didClearWindowObject:(id)  windowObject forFrame:(WebFrame*)frame {! [windowObject s...
JS Global  - (void)webView:(id)sender didClearWindowObject:(id)  windowObject forFrame:(WebFrame*)frame {! [windowObject s...
JS Global    - (void)webView:(id)sender didClearWindowObject:(id)    windowObject forFrame:(WebFrame*)frame {! [windowObje...
JS Global    - (void)webView:(id)sender didClearWindowObject:(id)    windowObject forFrame:(WebFrame*)frame {! [windowObje...
JS Global    - (void)webView:(id)sender didClearWindowObject:(id)    windowObject forFrame:(WebFrame*)frame {! [windowObje...
JS Global    - (void)webView:(id)sender didClearWindowObject:(id)    windowObject forFrame:(WebFrame*)frame {! [windowObje...
JS Global    - (void)webView:(id)sender didClearWindowObject:(id)    windowObject forFrame:(WebFrame*)frame {! [windowObje...
Apple
Apple  + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector   aSelector
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name         JS
RPC
RPC          http://localcall/func_name?argument=”a_json_string”
RPC          http://localcall/func_name?argument=”a_json_string”
Ajax
AjaxXMLHttpRequest
AjaxXMLHttpRequest
AjaxXMLHttpRequest                 Cache
Ajax     XMLHttpRequest                                         Cache- (NSCachedURLResponse *)cachedResponseForRequest:(NS...
Callback
Callbackwindow.location.href
Callbackwindow.location.href
Callback          window.location.href- (BOOL)webView:(UIWebView *)webView2shouldStartLoadWithRequest:(NSURLRequest *)requ...
Callback          window.location.href- (BOOL)webView:(UIWebView *)webView2shouldStartLoadWithRequest:(NSURLRequest *)requ...
Callback          window.location.href- (BOOL)webView:(UIWebView *)webView2shouldStartLoadWithRequest:(NSURLRequest *)requ...
FormIframeScript          webview  cache
Read The F**king SourceCode.https://github.com/linluxiang/JavascriptCallObjCExample
Javascript call ObjC
Javascript call ObjC
Javascript call ObjC
Javascript call ObjC
Javascript call ObjC
Javascript call ObjC
Javascript call ObjC
Javascript call ObjC
Javascript call ObjC
Javascript call ObjC
Upcoming SlideShare
Loading in...5
×

Javascript call ObjC

2,588

Published on

A way of calling objc function from js in UIWebView.

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,588
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
30
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Javascript call ObjC

  1. 1. iOS dev HACK! JS ObjC linluxiang@gmail.com
  2. 2. HTML
  3. 3. HTMLJS Objc
  4. 4. HTMLJS ObjcUIWebView
  5. 5. JS Global
  6. 6. JS Global- (void)webView:(id)sender didClearWindowObject:(id)windowObject forFrame:(WebFrame*)frame {
  7. 7. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame {! [windowObject setValue:localcall forKey:@"localcall"];
  8. 8. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame {! [windowObject setValue:localcall forKey:@"localcall"];
  9. 9. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame {! [windowObject setValue:localcall forKey:@"localcall"];}
  10. 10. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame {! [windowObject setValue:localcall forKey:@"localcall"];} + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
  11. 11. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame {! [windowObject setValue:localcall forKey:@"localcall"];} + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector + (BOOL)isKeyExcludedFromWebScript:(const char *)name
  12. 12. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame {! [windowObject setValue:localcall forKey:@"localcall"];} + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector + (BOOL)isKeyExcludedFromWebScript:(const char *)name
  13. 13. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame {! [windowObject setValue:localcall forKey:@"localcall"];} + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector + (BOOL)isKeyExcludedFromWebScript:(const char *)name
  14. 14. Apple
  15. 15. Apple + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector aSelector
  16. 16. + (BOOL)isKeyExcludedFromWebScript:(const char *)name
  17. 17. + (BOOL)isKeyExcludedFromWebScript:(const char *)name
  18. 18. + (BOOL)isKeyExcludedFromWebScript:(const char *)name JS
  19. 19. RPC
  20. 20. RPC http://localcall/func_name?argument=”a_json_string”
  21. 21. RPC http://localcall/func_name?argument=”a_json_string”
  22. 22. Ajax
  23. 23. AjaxXMLHttpRequest
  24. 24. AjaxXMLHttpRequest
  25. 25. AjaxXMLHttpRequest Cache
  26. 26. Ajax XMLHttpRequest Cache- (NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)request
  27. 27. Callback
  28. 28. Callbackwindow.location.href
  29. 29. Callbackwindow.location.href
  30. 30. Callback window.location.href- (BOOL)webView:(UIWebView *)webView2shouldStartLoadWithRequest:(NSURLRequest *)requestnavigationType:(UIWebViewNavigationType)navigationType
  31. 31. Callback window.location.href- (BOOL)webView:(UIWebView *)webView2shouldStartLoadWithRequest:(NSURLRequest *)requestnavigationType:(UIWebViewNavigationType)navigationType [webview loadData]
  32. 32. Callback window.location.href- (BOOL)webView:(UIWebView *)webView2shouldStartLoadWithRequest:(NSURLRequest *)requestnavigationType:(UIWebViewNavigationType)navigationType [webview loadData]- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script;
  33. 33. FormIframeScript webview cache
  34. 34. Read The F**king SourceCode.https://github.com/linluxiang/JavascriptCallObjCExample
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×