Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to a MySQL database using Xcode and Objective-C

I have been interested in working with a MySQL database in my iPhone or Mac projects. How is a connection performed in Objective-C?

I only had a bit of experience with PHP, but heck, that is a bit too different =/

like image 397
Voldemort Avatar asked Feb 01 '11 02:02

Voldemort


3 Answers

Check this tutorial for connectivity with SQLite.

You will not be able to connect to MySQL directly from the iPhone. You must use some intermediate layer such as a Web application with PHP.

So, you will have something like this:

  1. iPhone POSTING a request to the WebServer using HTTP
  2. Web Server connecting to the MySQL database
  3. Web Server returning data to the iPhone (XML, plain text)
  4. iPhone processing the data

You can use this technique to query and insert/update/delete data.

Once I found this library for MySQL, and I am aware how it works.

like image 139
KingofBliss Avatar answered Oct 06 '22 00:10

KingofBliss


It's a much better option not to deal directly with MySQL, but use Apple's Core Data API.

It allows you to manage an relational database without having to write SQL. It's very fast, very useful. Good stuff.

like image 40
Kenny Wyland Avatar answered Oct 05 '22 23:10

Kenny Wyland


Try absrd which recycles connections across concurrent threads (queues).

like image 25
hernan saab Avatar answered Oct 06 '22 00:10

hernan saab