SlideShare a Scribd company logo
1 of 44
Download to read offline
iOS dev HACK!
     JS    ObjC
 linluxiang@gmail.com
HTML
HTML

JS     Objc
HTML

JS     Objc

UIWebView
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 setValue:localcall forKey:@"localcall"];
JS Global

  - (void)webView:(id)sender didClearWindowObject:(id)
  windowObject forFrame:(WebFrame*)frame {

! [windowObject setValue:localcall forKey:@"localcall"];
JS Global

    - (void)webView:(id)sender didClearWindowObject:(id)
    windowObject forFrame:(WebFrame*)frame {

! [windowObject setValue:localcall forKey:@"localcall"];

}
JS Global

    - (void)webView:(id)sender didClearWindowObject:(id)
    windowObject forFrame:(WebFrame*)frame {

! [windowObject setValue:localcall forKey:@"localcall"];

}

    + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
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
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
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
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
Ajax

XMLHttpRequest
Ajax

XMLHttpRequest
Ajax

XMLHttpRequest




                 Cache
Ajax

     XMLHttpRequest




                                         Cache

- (NSCachedURLResponse *)cachedResponseForRequest:
(NSURLRequest *)request
Callback
Callback
window.location.href
Callback
window.location.href
Callback
          window.location.href



- (BOOL)webView:(UIWebView *)webView2
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)
navigationType
Callback
          window.location.href



- (BOOL)webView:(UIWebView *)webView2
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)
navigationType

                  [webview loadData]
Callback
          window.location.href



- (BOOL)webView:(UIWebView *)webView2
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)
navigationType

                  [webview loadData]

- (NSString *)stringByEvaluatingJavaScriptFromString:
(NSString *)script;
Form

Iframe

Script

          webview
  cache
Read The F**king SourceCode.

https://github.com/linluxiang/
JavascriptCallObjCExample

More Related Content

What's hot

The Promised Land (in Angular)
The Promised Land (in Angular)The Promised Land (in Angular)
The Promised Land (in Angular)Domenic Denicola
 
Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4DEVCON
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingJace Ju
 
TDD of HTTP Clients With WebMock
TDD of HTTP Clients With WebMockTDD of HTTP Clients With WebMock
TDD of HTTP Clients With WebMockBartosz Blimke
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Satoshi Asano
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "FDConf
 
Testing http calls with Webmock and VCR
Testing http calls with Webmock and VCRTesting http calls with Webmock and VCR
Testing http calls with Webmock and VCRKerry Buckley
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -Kenji Tanaka
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4DEVCON
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.jsWebsecurify
 
Client server part 12
Client server part 12Client server part 12
Client server part 12fadlihulopi
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioCaesar Chi
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to NodejsGabriele Lana
 
HTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - AltranHTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - AltranRobert Nyman
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHPThomas Weinert
 

What's hot (20)

The Promised Land (in Angular)
The Promised Land (in Angular)The Promised Land (in Angular)
The Promised Land (in Angular)
 
Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstraping
 
TDD of HTTP Clients With WebMock
TDD of HTTP Clients With WebMockTDD of HTTP Clients With WebMock
TDD of HTTP Clients With WebMock
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "
 
Testing http calls with Webmock and VCR
Testing http calls with Webmock and VCRTesting http calls with Webmock and VCR
Testing http calls with Webmock and VCR
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
 
Client server part 12
Client server part 12Client server part 12
Client server part 12
 
Nevermore Unit Testing
Nevermore Unit TestingNevermore Unit Testing
Nevermore Unit Testing
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.io
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 
HTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - AltranHTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - Altran
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 

Similar to Javascript call ObjC

Gdg dev fest hybrid apps your own mini-cordova
Gdg dev fest hybrid apps  your own mini-cordovaGdg dev fest hybrid apps  your own mini-cordova
Gdg dev fest hybrid apps your own mini-cordovaAyman Mahfouz
 
Hybrid apps - Your own mini Cordova
Hybrid apps - Your own mini CordovaHybrid apps - Your own mini Cordova
Hybrid apps - Your own mini CordovaAyman Mahfouz
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platformsAyush Sharma
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용NAVER D2
 
PhoneGap_Javakuche0612
PhoneGap_Javakuche0612PhoneGap_Javakuche0612
PhoneGap_Javakuche0612Yuhei Miyazato
 
Writing JavaScript for C# Blazor.pptx
Writing JavaScript for C# Blazor.pptxWriting JavaScript for C# Blazor.pptx
Writing JavaScript for C# Blazor.pptxEd Charbeneau
 
A portlet-API based approach for application integration
A portlet-API based approach for application integrationA portlet-API based approach for application integration
A portlet-API based approach for application integrationwhabicht
 
JavaScript Web Development
JavaScript Web DevelopmentJavaScript Web Development
JavaScript Web Developmentvito jeng
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyMark Meeker
 
Finch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with FinagleFinch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with FinagleVladimir Kostyukov
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM patternNAVER Engineering
 
Quickly function add by Eclipse Monkey
Quickly function add by Eclipse MonkeyQuickly function add by Eclipse Monkey
Quickly function add by Eclipse Monkeybose999
 
Lift 2 0
Lift 2 0Lift 2 0
Lift 2 0SO
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it meansRobert Nyman
 

Similar to Javascript call ObjC (20)

UIWebView Tips
UIWebView TipsUIWebView Tips
UIWebView Tips
 
Gdg dev fest hybrid apps your own mini-cordova
Gdg dev fest hybrid apps  your own mini-cordovaGdg dev fest hybrid apps  your own mini-cordova
Gdg dev fest hybrid apps your own mini-cordova
 
Hybrid apps - Your own mini Cordova
Hybrid apps - Your own mini CordovaHybrid apps - Your own mini Cordova
Hybrid apps - Your own mini Cordova
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
 
React native by example by Vadim Ruban
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim Ruban
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용
 
PhoneGap_Javakuche0612
PhoneGap_Javakuche0612PhoneGap_Javakuche0612
PhoneGap_Javakuche0612
 
Writing JavaScript for C# Blazor.pptx
Writing JavaScript for C# Blazor.pptxWriting JavaScript for C# Blazor.pptx
Writing JavaScript for C# Blazor.pptx
 
A portlet-API based approach for application integration
A portlet-API based approach for application integrationA portlet-API based approach for application integration
A portlet-API based approach for application integration
 
Intro to Sail.js
Intro to Sail.jsIntro to Sail.js
Intro to Sail.js
 
JavaScript Web Development
JavaScript Web DevelopmentJavaScript Web Development
JavaScript Web Development
 
Scripting GeoServer
Scripting GeoServerScripting GeoServer
Scripting GeoServer
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case Study
 
Finch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with FinagleFinch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with Finagle
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
 
Quickly function add by Eclipse Monkey
Quickly function add by Eclipse MonkeyQuickly function add by Eclipse Monkey
Quickly function add by Eclipse Monkey
 
Lift 2 0
Lift 2 0Lift 2 0
Lift 2 0
 
Server Side Swift: Vapor
Server Side Swift: VaporServer Side Swift: Vapor
Server Side Swift: Vapor
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
5.node js
5.node js5.node js
5.node js
 

Javascript call ObjC

  • 1. iOS dev HACK! JS ObjC linluxiang@gmail.com
  • 2.
  • 4. HTML JS Objc
  • 5. HTML JS Objc UIWebView
  • 6.
  • 8. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame {
  • 9. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame { ! [windowObject setValue:localcall forKey:@"localcall"];
  • 10. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame { ! [windowObject setValue:localcall forKey:@"localcall"];
  • 11. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame { ! [windowObject setValue:localcall forKey:@"localcall"]; }
  • 12. JS Global - (void)webView:(id)sender didClearWindowObject:(id) windowObject forFrame:(WebFrame*)frame { ! [windowObject setValue:localcall forKey:@"localcall"]; } + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
  • 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. 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
  • 15. 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
  • 16.
  • 17. Apple
  • 18. Apple + (BOOL)isSelectorExcludedFromWebScript: (SEL)aSelector aSelector
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 27.
  • 28. RPC
  • 29. RPC http://localcall/func_name? argument=”a_json_string”
  • 30. RPC http://localcall/func_name? argument=”a_json_string”
  • 31. Ajax
  • 35. Ajax XMLHttpRequest Cache - (NSCachedURLResponse *)cachedResponseForRequest: (NSURLRequest *)request
  • 39. Callback window.location.href - (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType) navigationType
  • 40. Callback window.location.href - (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType) navigationType [webview loadData]
  • 41. Callback window.location.href - (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType) navigationType [webview loadData] - (NSString *)stringByEvaluatingJavaScriptFromString: (NSString *)script;
  • 42. Form Iframe Script webview cache
  • 43.
  • 44. Read The F**king SourceCode. https://github.com/linluxiang/ JavascriptCallObjCExample