最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using 'Core Data' with Phonegap? - Stack Overflow

programmeradmin2浏览0评论

Does it make sense to use 'Core Data' for storage in a Phonegap-based hybrid iPhone/iPad app? Our app is mainly going to run inside a UIWebView, but the data-storage ponent is going to be central to the working of the app. I know Mobile Safari has offline storage capability which can be used via PhoneGap, but we already have an in-house data-storage solution build on top of Core Data that we would like to leverage.

Thanks Kapil

Does it make sense to use 'Core Data' for storage in a Phonegap-based hybrid iPhone/iPad app? Our app is mainly going to run inside a UIWebView, but the data-storage ponent is going to be central to the working of the app. I know Mobile Safari has offline storage capability which can be used via PhoneGap, but we already have an in-house data-storage solution build on top of Core Data that we would like to leverage.

Thanks Kapil

Share Improve this question asked Dec 13, 2010 at 20:41 kapilkapil 511 silver badge2 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

You could create a PhoneGap plug-in, which is a custom extension to the PhoneGap API. It includes a bit of native code that does some native-specific functionality, as well as a JavaScript interface that then exposes this functionality to you, the PhoneGap developer. By definition, a plug-in is platform-specific!

In your case, you would create a plug-in that exposes the Core Data API to the PhoneGap browser instance. Presumably, since you already have a bunch of the Core Data-based code written, the majority of the work is done. You simply have to write the JavaScript wrapper around it and form your native code so that it fits into the plugin pattern.

A good place to start would be Jesse's blog post about them; note that these are specifically for iPhone:

http://blogs.nitobi./jesse/2010/04/01/iphonegap-plugs/

Here are some examples of existing PhoneGap plugins, how to use them, and links within to the source code to see how they were built:

https://github./phonegap/phonegap-plugins

http://blogs.nitobi./shazron/2010/07/12/phonegap-iads-plugin/

http://blog.urbanairship./blog/2010/06/09/phonegap-push/

Here's one by fellow StackOverflower and answerer above, Aaron :)

http://blog.clearlyinnovative./post/1097750723/phonegap-plugin-for-downloading-url

Hope that helps!

i think if you have already made that investment, why not just write a native application?

you are going to have to do some "interesting" things to get the PhoneGap application to integrate with your CoreData solution.

isn't it possible to use PhoneGap's own localStorage API (which is an SQLite db, btw)?

http://docs.phonegap./en/2.5.0/cordova_storage_storage.md.html

发布评论

评论列表(0)

  1. 暂无评论