dimanche 10 mai 2015

How to use special character in NSURL?

My application is using an NSURL like this:

var url = NSURL(string: "http://ift.tt/1cldTmx")

When I tried to make a task for getting data from this NSURL like this:

    let task = NSURLSession.sharedSession().dataTaskWithURL(url!, completionHandler: { (data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in

        if error == nil {

            var urlContent = NSString(data: data, encoding: NSUTF8StringEncoding)
            println("urlContent \(urlContent!)")
        } else {

            println("error mode")
        }

but I got error when trying to got data from that address, although when I using safari go to link: "http://ift.tt/1RqI2S6=Aïn+Béïda+Algeria&country=" I can see the data. How can I fix that?

Aucun commentaire:

Enregistrer un commentaire