0

I have some javascript code that I need to execute from an objective-c (iPhone) app.

The javascript code needs some of the values from the iPhone app. What I mean is, there is a spot in the iPhone app (a textbox) for a user to type their name. Then the javascript code that runs will be: alert(name)

where the name variable is really textbox.text

How can I do this from objective-c, without relying on an external webserver?

Thank you!

2
  • Thanks. I looked at those, but I'm afraid neither offers what I'm looking for -- most seem to rely on an external server. Commented Oct 27, 2011 at 22:10
  • Is it a major problem if my javascript does not have a return value? Commented Oct 27, 2011 at 22:42

1 Answer 1

1

Add a UIWebView and inject a <script> tag containing the JavaScript using [webview loadHTMLString: html]

Sign up to request clarification or add additional context in comments.

7 Comments

Wouldn't that rely on a webserver, though?
No, loadHTMLString takes standalone HTML, no need for a web server.
Thanks. Is there a way to make the webView invisible?
Yes, all UIView objects have a hidden property
Is it a major problem if my javascript does not have a return value?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.