[Solved] How to convert Objective-C to Swift [closed]


This is more correct than iPrabu’s answer, which is incomplete.

let deviceTokenString = deviceToken.debugDescription.stringByReplacingOccurrencesOfString(">", withString: "").stringByReplacingOccurrencesOfString("<", withString: "").stringByReplacingOccurrencesOfString(" ", withString: "")

let link = "http://emlscer.no-ip.info:8080/sample/iAppList.php?add=\(deviceTokenString)"

if let
    escapedString = link.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding),
    url = NSURL(string: escapedString)
{
    var request = NSMutableURLRequest(URL: url)
    request.HTTPMethod = "GET"
    do {
        try NSURLConnection.sendSynchronousRequest(request, returningResponse: nil)
    } catch {
        // Handle your error
    }
}

1

solved How to convert Objective-C to Swift [closed]