I am developing an app using Swift. In my app, I am getting a value from a UITextField
and a UITextView
and sending that value as a parameter to a JSON API. I am able to send the value, but when I send the value with white space, my app crashes and shows error as null value. But I need to send the value with space also. For example, getting the full name or address.
Code:
Alamofire.request(.GET, "https://www.something.com/cid="+MyCustId+"", parameters: nil, encoding: .URL, headers: nil).response { (req, res, data, error) -> Void in
let dataString = NSString(data: data!, encoding:NSUTF8StringEncoding)
print(dataString)
}
Here, MyCustId
is the variable which is getting the value from UITextField
. Thanks in advance!