Database connectivity within an iPhone application
I was wondering if there were any good sources or documents that could explain to me how I can can开发者_JAVA百科not to a PostgreSQL database from within my iPhone application.
Also, if they could go beyond just connecting, and explain how to use PL/SQL and Object Persistence within the Objective C iPhone SDK framework as well, that would be awesome.
Thanks!
-Scott
Or you can use PGSQLKit for iOS. Look for it on http://www.postgresqlformac.com
For starters you need to compile libpq the library that is used to interact with PostgreSQL. See this link where I went through doing that -> Connect iPhone App to PostgreSQL Using Libpq. Make note of my issue in my linked answer. The iphone simulator needs libpq compile for the mac machines processor while the real iphone needs the libpq compiled for the arm processor.
Once you have libpq working you should be able to follow the docs at the postgresql site - http://www.postgresql.org/docs/8.4/interactive/libpq.html.
From what I have found there is no book from start to finish that will cover what you want, you will have to go MacGyver style to figure things out. To learn how to use PL/PGSQL you will want to use the postgresql documents found at www.postgresql.org. There is nothing special about PL/PGSQL being used from the iPhone compared to the desktop. Other than you want to consider your devices constraints and bandwidth/charges. Also the docs on postgresql.org show you how to connect to a database using libpq so there isn't much anyone can do aside from copy the code from the online docs and paste them here for you.
Hope this sheds some light.
精彩评论