dimanche 19 juin 2016

Pass an array response from PHP to iOS app ( using Swift )


I am quite new to iOS dev. Now, I have a website that I would like to bring on iOS platform as an app.

It should be simple, as my website is quite simple. But I need to get an array(quite big) from PHP to Swift.

This is how it should happen:

Request from Swift to PHP: we send a variable; for example a name: Jack.

Than my PHP script is ready to process this variable and return an array with a few content, an array like this:

1 : "ImageURL1" - "Description1" -"Title1" 2 : "ImageURL2" - "Description2" -"Title2";

How do I get this array to Swift. For now, I just know I should be using JSON to transform the array and echo it on the PHP side, but I am very new with Swift to get the JSON variable.

Could you guys help? Thanks alot. (Any url that can help me, is very welcome).

The php variable will be like this:

    $contents[id][content]

like for example :

    echo $contents[1]['Title']. " - ". $contents[3]['URL']; 

will give: Title1 - URL3.


Aucun commentaire:

Enregistrer un commentaire