Swift - Send an array as POST request parameter to PHP
<p>I'm working on an app in Swift. I need to call PHP webservice from this app.</p>

<p>Below code for webservice:</p>

<pre><code>//  ViewController.swift
//  SwiftPHPMySQL
//
//  Created by Belal Khan on 12/08/16.
//  Copyright © 2016 Belal Khan. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

//URL to our web service
let URL_SAVE_TEAM = "http://192.168.1.103/MyWebService/api/createteam.php"


//TextFields declarations
@IBOutlet weak var textFieldName: UITextField!
@IBOutlet weak var textFieldMember: UITextField!



//Button action method
@IBAction func buttonSave(sender: UIButton) {

    //created NSURL
    let requestURL = NSURL(string: URL_SAVE_TEAM)

    //creating NSMutableURLRequest
    let request = NSMutableURLRequest(URL: requestURL!)

    //setting the method to post
    request.HTTPMethod = "POST"

    //getting values from text fields
    let teamName=textFieldName.text
    let memberCount = textFieldMember.text

    //creating the post parameter by concatenating the keys and values from text field
    let postParameters = "name="+teamName!+"&amp;member="+memberCount!;

    //adding the parameters to request body
    request.HTTPBody = postParameters.dataUsingEncoding(NSUTF8StringEncoding)


    //creating a task to send the post request
    let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
        data, response, error in

        if error != nil{
            print("error is \(error)")
            return;
        }

        //parsing the response
        do {
            //converting resonse to NSDictionary
            let myJSON =  try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary

            //parsing the json
            if let parseJSON = myJSON {

                //creating a string
                var msg : String!

                //getting the json response
                msg = parseJSON["message"] as! String?

                //printing the response
                print(msg)

            }
        } catch {
            print(error)
        }

    }
    //executing the task
    task.resume()

}


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}
</code></pre>

<p>I have this array:</p>

<pre><code>let arr = ["aaa", "wassd", "wesdsd"]
</code></pre>

<p>Now I need to send this array as parameter like this:</p>

<pre><code>let postParameters = "name="+teamName!+"&amp;member="+memberCount!;
</code></pre>

<p>I've done this:</p>

<pre><code>let postParameters = "name="+teamName!+"&amp;member="+memberCount!+"&amp;arr="+arr;
</code></pre>

<p>but getting this error:</p>

<blockquote>
  <p>Expression was too long to be solved in a reasonable time. consider breaking the expression into distinct sub expressions.</p>
</blockquote>

<p>Any help would be appreciated.</p>