How can I write an iPhone app entirely in JavaScript without making it just a web app?

前端 未结 10 1489
离开以前
离开以前 2020-12-07 07:22

I don\'t want to take the time to learn Obj-C. I\'ve spent 7+ years doing web application programming. Shouldn\'t there be a way to use the WebView and just write the whole

相关标签:
10条回答
  • 2020-12-07 07:37

    Titanium Mobile is also an option - it allows you to write JavaScript that gets translated into Objective-C.

    0 讨论(0)
  • 2020-12-07 07:41

    You should have the native wrapper written in Objective C. This wrapper could contain really few lines of code (like, 10) necessary to create a WebView and navigate it to the given address in the internet (where your application resides). But in this case your application should be a full-featured web application (I mean, use not only the JavaScript, but also some HTML for markup).

    0 讨论(0)
  • 2020-12-07 07:48

    For those doing this on iPhone 2.1 (maybe 2.0), you do NOT need to create any special services for local data storage. MobileSafari appears to support the HTML5/WHATWG SQL database API. This is the same API supported by recent versions of desktop Safari and Firefox.

    If you're using a toolkit like Dojo or ExtJS that offers a storage abstraction, your code should work on just about any modern browser, including MobileSafari.

    To test, open http://robertsanders.name/dev/stackoverflow/html5.html on your iPhone.

    If you open that page then look on the filesystem of a Jailbroken iPhone, you should see a database somewhere in /private/var/mobile/Library/WebKit/Databases/. There's even a directory of web-opened DBs there.

    root# sqlite3 /private/var/mobile/Library/WebKit/Databases/Databases.db SQLite version 3.5.9 Enter ".help" for instructions

    sqlite> .databases seq name file


    0 main /private/var/mobile/Library/WebKit/Databases/Databases.db

    sqlite> .tables

    Databases Origins

    sqlite> select * from Databases;

    1|http_robertsanders.name_0|NoteTest|Database|API example|20000|0000000000000001.db

    sqlite> select * from Origins;

    http_robertsanders.name_0|5242880

    0 讨论(0)
  • 2020-12-07 07:50

    I ran into this same problem. I already have a game written entirely in Javascript. I would love to make an iPhone friendly version, but Obj-C is an overkill. What I ended up doing was using the WebView to point to a special url of the iphone app. After thinking about it, I suppose I could just move those files to the app directory and run them locally.

    0 讨论(0)
提交回复
热议问题