any one who try to connect postgresql with xcode for ios application? What should i try? what do you suggest?
Asked
Active
Viewed 4,058 times
1 Answers
4
The usual approach is to avoid making a direct connection but to route everything through an HTTP based API.
The iOS application then only needs to perform HTTP requests and parse the responses (which you can format using JSON).
You can write the HTTP API in the server side language of your choice.
It is possible to connect directly to the database, but you would have to write or otherwise acquire a Postgresql client library for iOS (which appears to exist, thanks Craig) and expose the database on the network (if the iOS application is going to connect over the Internet that means exposing the database directly to the Internet, which is generally considered to be a Bad Idea).
-
A reasonable choice for an easy-to-implement API (if you know a little Java) is a Java JAX-RS implementation like Jackson and the PgJDBC driver. If you use a Java EE 6 server like JBoss AS 7 it all comes built-in. Just one of many choices, of course. – Craig Ringer Jul 10 '12 at 12:56
-
1It also seems that libpq has been built for iOS. I do *not* recommend this approach, though. http://stackoverflow.com/questions/4508997/compiling-libpq-with-ios-sdk-4-2 – Craig Ringer Jul 10 '12 at 12:58
-
If you go the web service route a very simple tool to use is to use nodejs. There are postgre libs that will allow you to connect to a postgres database. A simple example can be found here http://stackoverflow.com/questions/9205496/play-with-postgres-through-node-js/9214036#9214036. This would allow you to have a webservice on your dev machine in 30 minutes including setup. – Kuberchaun Jul 10 '12 at 16:10