2

any one who try to connect postgresql with xcode for ios application? What should i try? what do you suggest?

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

3 Comments

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.
It also seems that libpq has been built for iOS. I do not recommend this approach, though. stackoverflow.com/questions/4508997/…
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 stackoverflow.com/questions/9205496/…. This would allow you to have a webservice on your dev machine in 30 minutes including setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.