Featured iPhone Development Resources

Access Native Objective-C Code In Javascript Iphone Apps

Yesterday, I told you how to execute Javascript code on a page showing in a UIWebView using Objective-C. That was rather trivial as Apple has messaging functionality built in to allow that. Executing Objective-C code from within a Javascript application is not trivial. I highly suggest using one of the three frameworks I mentioned in a previous post.

Now, this is something that I haven’t coded myself because I haven’t run into a situation where I was using a web app that needed to add functionality not already implemented within Phonegap when working with Iphone web app code. However, the author of QuickConnect has an excellent tutorial on doing this here.

Basically what you do is write to NSLog from your Javascript code, then iterate through that log and extract the commands and variables to be used by your Objective-C code.   Overall, it’s not a very complex process, but a rather tedious one.

Thanks for reading this series about turning Javascript web apps into native ones for the Iphone app store, tommorow I will talk a bit about OpenGL ES.

1 reply on “Access Native Objective-C Code In Javascript Iphone Apps”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.