1

To start, here is what I have implemented already.

  • Working* Windows Time Clock application that is currently being used by employees.
  • Windows Application connects to a Database of MySQL type located on a local server.

I have a skeleton of an iPhone application that will perform the same functions as the Windows Time Clock application. How can I send/receive information to/from the MySQL server from the iPhone application? I've seen it done so I know its possible. I would use SQLite, however, the MySQL Database is already created and this application isn't the only application accessing the data. Any help would be appreciated.

I've searched all over here and all of the tutorials seem pretty out-dated and not very easy to understand. Can someone point me in the right direction on how to do this? I am aware of frameworks that can be installed and using JSON, XML, SOAP, and other services but there isn't a clear tutorial on how to do this from start to finish. It seems that this is a big question on here so if anyone has a clear, concise answer, that would be awesome. Thanks

1
  • (very old question!) the overwhelmingly popular way to do this now is just github.com/groue/GRDB.swift - it is dead easy. INFINITELY better than crap like "SwiftData" , core data etc. Commented Sep 7, 2024 at 19:18

3 Answers 3

2

I'm not familiar with the MySQL C Client Library but from my experience I usually set up a php(could be RoR, Python, etc.) web service to talk to the MySQL DB then use AFNetworking to easily send REST requests to the web service. Which will most likely send and receive JSON format data. This is kinda the standard for dealing with remote databases.

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

4 Comments

Is there a tutorial on how to do this? I'm talking like a start to finish tutorial.
Not to be rude, but stack overflow isn't a forum to just ask for tutorials. I recommend you research what others are using and figure out what method works best for you. If you Google creating a php RESTful web service and read the basic AFNetworking documentation you will be up in no time and be far more successful in the long run than reproducing a tutorial
But, if you're still looking for a solid foundation check out raywenderlich.com there's a bunch of tutorials 'from start to finish' there.
thanks for the information. I'm new to programming and google searching is turning up a bunch of stuff that assumes you are already an expert programmer. Thanks again
1

You can use the MySQL C Client Library and link that into your iOS app. Then your app will be able to connect to the MySQL database and issue SQL directly to it. It sounds like that is basically what your Windows app is already doing.

Since any C code works with Objective-C, you can use just about any plain C library in an iOS app.

In this case both your Windows app and your iOS will be talking directly to the database, without any kind of application layer to do validation, authentication, etc. If you wanted an server application to be responsible for those sort of things, you would have to create one and then your app would communicate with it, using JSON or XML or SOAP or whatever you like.

You will have to be mindful of making sure the database is secure; for example, if the iOS app connects with root DB access, a bug or a malicious user could figure out how to use it to make arbitrary changes to the database. (Since this is a time tracking app, you got your motive right there.) In summary: don't ignore security.

Here's the MySQL docs on the C API: http://dev.mysql.com/doc/refman/5.1/en/c.html

Here's a tutorial for the C API: http://zetcode.com/tutorials/mysqlcapitutorial/

Here's a code snippet from someone who has used the library on iOS: http://blog.iosplace.com/?p=30

2 Comments

Thanks for the information. So I have to download the MySQL C Client Library and add it to the app in Xcode correct? Then I can use the links you provided to integrate it into my application?
@CharlesVincent More or less. Note that you'll have to use an x86 version of the library on the iOS simulator and an ARM version on an iOS device. If these aren't downloadable you'll have to compile them from source. I recommend going as far as you can and then asking a new (specific) question if you run into a roadblock.
0

Use the library OHMySQL. It copes with MySQL through MySQL C API. It is written in Objective-C but also can be applied to the project in Swift. And it supports iOS and macOS. enter image description here

2 Comments

GRDB is SQLite and OHMySQL is for MySQL. These are different DBs
quite right @Oleg - sorry for the drunk post :)

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.