I'm in the process of learning Swift coding and decided to attempt a porting of one of my existing Windows programs.
The thing is, that program relies heavily on connecting to a remote MySQL server.

I've seen a few attempts to provide various connectors to an assortment of databases, including MySQL.
Most solutions say that it can be done using a bridge to Object C, but none really show how.

Does anyone here have any experience in connecting a Cocoa/Swift application to a MySQL server (or any remote database at all)?

Recommended Answers

All 4 Replies

Is this a mobile app? If it is you can use sqlite instead, it is supported pretty well in objective c so I guess Swift is the same (haven't got around to updating my iOS knowledge base yet).
Otherwise, if you need to connect to a remote MySQL serve you may have to add another layer, a PHP webservice or similar, that the app connects to and that passes the requests on to the database.
Then you just need to pass info back and forth as JSON and you shouldn't have any issues.

I know that I could use a webservice if this was for iOS (or a webapplication!).
But because I said that I'm porting a Windows program, I would think that it was obvious. Appearently not.
This is for OSX Mavericks and Yosemite, not iOS.

The whole point of creating a program with a database backend, local or remote, is to not have to use webservices.

And while I'm asking.
Is there such a thing as an equivalent of DataSets/DataTables in Cocoa/Swift to make things easier?


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.