swift - Error: "HttpGetData.Type doesn't have a member named 'url'" -
i want test http post, shows error:
httpgetdata.type 'doesn't have member named 'url'
when type on viewcontroller works?
is initialize problem?
import foundation public class httpgetdata{ let url = nsurl( string: "https://210.61.209.194:8443/smarttvwebservicetopmsoapi/") let request = nsmutableurlrequest((url : url)!) request.httpmethod = "post" let poststring : string = "id=13&name=jack" request.httpbody = poststring.datausingencoding(nsutf8stringencoding) let task = nsurlsession.sharedsession().datataskwithrequest(request) { data, response, error in if error != nil { println("error=\(error)") return } println("response = \(response)") let responsestring = nsstring(data: data, encoding: nsutf8stringencoding) println("responsestring = \(responsestring)") } task.resume() }
Comments
Post a Comment