0

If I have a webbased app, wrapped in a UIWebView, can I execute Objective C code form within the HTML code?

I hope I don't get downvoted to oblivion for asking this but I am not able to find anything online.

Zia
  • 14,622
  • 7
  • 40
  • 59

3 Answers3

2

Doesn't C code need to be compiled? I don't think it can be executed within the HTML

redCodeAlert
  • 603
  • 2
  • 7
  • 18
1

Its impossible.

but if you trying to create HTML5 application its possible using webview; http://conecode.com/news/2011/05/ios-tutorial-creating-a-web-view-uiwebview/

in this case you need create your application with Javascript and HTML. I recoment you to download jquery mobile and bootstrap mobile too.

For a complex app use Phonegap: http://phonegap.com/

ErasmoOliveira
  • 1,416
  • 2
  • 20
  • 40
  • Thanks for the additional details. Side question. Is it possible to develop a platform independent web based app using phonegap? – Zia Feb 24 '15 at 20:12
  • 1
    @user2891327 the phonegap are used to access the mobile function / events. Use jquery mobile to create you implementations and views, The phonegap api is only to access the device functions. – ErasmoOliveira Feb 24 '15 at 20:16
0

I'm assuming you mean that you have an iOS app that contains a UIWebView, and you want your embedded javascript to call ObjC. If so, see: https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/ObjCFromJavaScript.html

There are libraries that build on top of Apple's code. I've used Jockey (https://github.com/tcoulter/jockeyjs) and it works pretty well.

More info here: iOS JavaScript bridge

Community
  • 1
  • 1
John Wallace
  • 161
  • 1
  • 2