Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

My First Web Service

neilq5neilq5 Posts: 2New Users Noob
I'm developing an application that heavily relies on a server backend with a MySQL Database.

I have a fairly good grasp on both Swift and PHP, but I've never used them together so I have a few questions:
  • I know how to make a POST request from Swift, what I don't know is how should I handle the data I get back from the server? For instance, If I was creating a login with a browser I would use $_SESSION for storing what I need. How does it work in Swift?
  • When connecting to PHP, how do I handle individual functions? I was thinking of perhaps using a switch statement based on one of the Post parameters which will call the relevant function I want. Would this be a good idea or should I have an individual PHP file for each task?

Any help would be much appreciated.
Tagged:

Replies

  • esko918esko918 esko918Posts: 227New Users @ @
    Server backends should return you either a JSON Object or an XML file. Then from there you parse the information in those objects. Its fairly easy for JSON. You just convert the JSON object to an NSArray, which would usually be an array of NSDIctionaries, or the base class can just be an NSDictionary depending upon how the server side programmer programmed it.

    Look into NSURLConnection as your starting point. From that class you will receive an NSData object holding the data returned in the connection. Cast the data into whatever data type that is being returned and work with the values from there.
  • neilq5neilq5 Posts: 2New Users Noob
    Thanks guys,

    Alomofire definitely looks like a step in the right direction.

    Will take your advice on board and get back to you if I have any other questions.
Sign In or Register to comment.