2

Crux

Calling a method defined in Objective C from a JS file. Phonegap framework is being used.

Objective C method

MyClassViewController.h file contains

-(int) returnTen;

MyClassViewController.m file contains

-(int) returnTen
{
     return 10;
}

What I want to do?

<html>
<head>
<title>Sample</title>

<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript">

    document.addEventListener("deviceready", onDeviceReady, false);

    function onDeviceReady() {
        var num = //Invoke "returnTen" so that 10 is stored in num variable
        pText.innerHTML = num;
    }

 </script>
 </head>
 </html>
2
  • 1
    Check this stackoverflow.com/questions/12049500/… Commented Aug 21, 2012 at 6:56
  • Thanks Arjun, but I've already wrote a blog post about how to do it in a better way. Sadly the blog post is now deleted. Commented Aug 22, 2012 at 7:42

0

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.