Question

I have experience writing Android code, but I'm totally new to iOS. I decided a good way to learn it was by creating an Android app and then porting it to iOS. Rather than having a full Android app and learning it wasn't going to port easily, I decided to port each piece as I write it.

I started with creating the Android SQLite database after after learning that iOS has SQLite as well, thinking this would be an easy place to get my feet wet.

I've been searching for how to port the Android code I wrote, but there's very little written that I can find. It seems more common to port going the other direction. To make it even worse, there seems to be a lack of iOS documentation on SQLite since something called CoreData is what is being suggested instead everwhere I turn.

I already have all the SQL statements in a contract, including all the SQL table definitions and indices, and ported them to C. However, I'm not finding any examples on using the contract on iOS.

Is there any documentation on this or an example? If not, did I misunderstand something?

Again, total iOS newbie here, so just a simple direction would be helpful.

thx.

Was it helpful?

Solution

Look on FMDB. It's Objective-C wrapper for SQLite. It has simple syntax, similar to SQLiteDatabase in Android. As far as I know there is nothing similar to Android contract for iOS development. Try to use FMDatabaseQueue from FMDB. It allows to access database in thread-safe manner.

P.S. CoreData is ORM for iOS and OS X. If you have Android contracts, it is much more easier to port them to iOS using FMDB.

OTHER TIPS

Core Data have its own data structure you can look at it and you will see something like this:

enter image description here

Tables from your model are prefixed by Z, so you can perfectly query this SQLite Database with SQL queries in Android.

Note: you can find this SQLite file after runnig your app with Simulator in the folder:

/Users/<you_name>/Library/Application Support/iPhone Simulator/<ios_version>/Applications/<app_id>/Documents/<app_name>.sqlite
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top