2014-10-09 19:08
浏览 86

将php json文件导入swift

I have a website that uses MySQL database. I'm trying to build an iOS app for it, so I wanted to use Swift to import information from the database and insert new information to it. I read that for the reading part I should use a PHP file to create a Json file, read that and extract the data. But I can't find the way to do it with swift.

Is there a way to connect iOS apps (written in Swift) to MySQL?

图片转代码服务由CSDN问答提供 功能建议

我有一个使用MySQL数据库的网站。 我正在尝试为它构建一个iOS应用程序,所以我 想要使用Swift从数据库导入信息并向其中插入新信息。 我读到,对于阅读部分,我应该使用PHP文件来创建一个Json文件,读取并提取数据。 但我找不到使用swift的方法。


  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsbqfrr098575666 2014-10-09 19:17

    In the client-server architecture, the client is completely separate from the server, and they just exchange data thanks to a common "language" (in your case, certain fields encoded in JSON).

    Your client is your iPhone app, written in Swift (but that's irrelevant).
    You now need to build a server, which is entirely separate from the app. You don't need Swift for that. You will need a server (for example a cheap cloud VPS on Amazon EC2, Rackspace Cloud Servers, Microsoft Azure...) and you will have to create another application that runs on that server.

    If it's just to pull data from a MySQL database, you can easily make that in PHP. Or you could use Node.js (which uses JavaScript: it's among the "trendiest" technologies at the moment), Ruby, Python, etc.
    For an example that uses PHP, you can check:
    To read the JSON data in your iOS app, then, you can use the builtin libraries: (it's available in Swift too)

    I don't know what your app is doing, but if you want to ignore all the things with the backend (the server) you can always consider something like Parse Core and let somebody else take care of the backend.

    打赏 评论

相关推荐 更多相似问题