Swift / MySQL / PHP:如何使用在线数据库编写ios应用程序

时间:2015-07-08 15:25:19

标签: php ios mysql swift

我刚刚在一家小公司做了一个学徒,我已经开发了与mysql DB一起在ARUBA中托管的管理Web应用程序。现在,对于我的“移动应用程序”课程,我想将iOS应用程序视为该Web应用程序的移动版本:实际上,我可以创建一个新的前端作为iOS应用程序。我应该使用Swift,我对iOS开发完全不熟悉。所以我想问一下你是否可以给我一些关于如何使用swift和php连接到数据库并执行CRUD操作的教程。在向我的老师提出这个想法之前,我想做一些练习,看看我是否能够创建这种应用程序。 你怎么说?

1 个答案:

答案 0 :(得分:2)

This course looks promising, though I haven't done it myself, so I'm not sure.

Think of this project in three parts:

  1. Creating your MySQL database
  2. Developing your PHP API to "talk to" the database - this is the mediator between the client and the database
  3. Developing the client code

It sounds like you've done some web development, so can I assume that you know how to do number 1 and 2 above? You can create the PHP almost exactly like you would for a website, and it has a great function (json_encode) to put everything you're sending to the client in JSON. There is a class called NSJSONSerialization to deal with the JSON received on the client end.

Do know that this is a big project; developing all the PHP and Swift code in addition to the database is no small feat.

To accomplish number 3, I would recommend reading up on NSURLSession. This tutorial and this tutorial may be useful.

相关问题