Comments (3)
There isn't a built-in syntax for doing that. GAJavaScript only allows invoking existing ObjC objects, via "GAJavaScript.performSelector(..)" or by invoking a block set on a JS object using [GAScriptObject setFunction:forKey:].
Can you provide more of an idea of what you want to accomplish?
from gajavascript.
performSelector executes a void method (selector)...
what I'm trying to accomplish are the 2 following scenarios:
- Create an instance of an existing ObjC object from a javascript script: for example create an instance of object foo and call a method on it.
- call a method in the ObjC runtime and get a result back: not only performing a void selector but executing a real invocation and return its result.
from gajavascript.
Those have both been hard to accomplish because the mechanism to invoke Objective-C from JS uses a UIWebViewDelegate callback that is invoked as a side-effect of URL navigation (e.g. location.replace or form.submit()). I believe I found a way to invoke Objective-C synchronously, using an iframe element and removing/adding it to the DOM. However, I haven't needed this and I'm not sure how reliable it is.
An alternative would be to have performSelector() take a callback function that would receive the return value of the Objective-C call. It's something that I haven't gotten around to yet. I might have some time to get to it in the next week or so, but if not, perhaps you or someone in the community could?
from gajavascript.
Related Issues (14)
- Need to add "--all_load & --ObjC" linker flags HOT 3
- How can I loop through DOM elements? HOT 4
- NSFastEnumeration broken when the object has more than 16 properties
- Refactor library to use ARC
- Block callbacks not invoked
- gajavascript_frame is not completely hidden
- Update WebView Explorer Demo
- Block callback args corrupted when arrays are passed HOT 1
- Readme.MD is outdated HOT 1
- Multiple UIWebView / GAScriptEngine & Caching Issues HOT 3
- Weird issue with GAJavascript.performSelector JS HOT 2
- Will GAJavascript work with UIWebView inside UITableViewCell? HOT 2
- Basic to integrate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gajavascript.