jeudi 13 août 2015

json with a foreign language swift

I'm using an API of a website to make an app for them , the app should send an SMS to the client after the client chose an item , the problem is when I try to send a message using the website api , if the message in english the app send it correctly but if it's in another language (in my case arabic) the app doesn't send the message

I tried to use the link with the arabic message in safari and it sent the message successfully , but in the app it doesn't work unless the message is in English

here is my code :

var link = "http://ift.tt/1L9P360"
        println(link)
        message.text = "\(link)"
        if let url = NSURL(string: link){
            println(url)
            var dataTask = NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in
                if(error != nil){
                    println("Error: \(error.localizedDescription)")
                }else{
                    var jsonError = NSError?()
                    if let jsonData = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &jsonError) as? NSDictionary {
                     println(jsonData)
                    }
                }
            })



            dataTask.resume()
        }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire