こんにちは私はいくつかのデータをwebserviceに渡しています。これはNSURL(string:fullURL)はエラーを返します
http://www.website.com/mobileapp/user.php?reg_device_id=566&alert_details=[{\n \"is_active\" = 1;\n \"term_id\" = 55;\n}, {\n \"is_active\" = 1;\n \"term_id\" = 2;\n}, {\n \"is_active\" = 1;\n \"term_id\" = 111;\n}, {\n \"is_active\" = 0;\n \"term_id\" = 21;\n}, {\n \"is_active\" = 0;\n \"term_id\" = 28;\n}, {\n \"is_active\" = 0;\n \"term_id\" = 1;\n}, {\n \"is_active\" = 0;\n \"term_id\" = 5;\n}, {\n \"is_active\" = 0;\n \"term_id\" = 4;\n}]
私のURLですこれは
for i in 0..<dm.array.count {
let id=dm.SettingsItems[i]["term_id"] as! String
var is_active="0"
if dm.array[i]
{
is_active="1"
}
let catRegDict:NSDictionary=["term_id":"\(id)","is_active":"\(is_active)"]
self.registerAyrray.append(catRegDict)
print("------REGISTER ARRAY------\(self.registerAyrray)")
}
let urlPath = "http://www.website.com/mobileapp/user.php?"
let path="reg_device_id=\(dm.DeviceID)&alert_details=\(self.registerAyrray)"
let fullURL = "\(urlPath)\(path)"
print(fullURL)
guard let endpoint = NSURL(string: fullURL) else {
print("Error creating endpoint")
return
}
let request = NSMutableURLRequest(URL:endpoint)
NSURLSession.sharedSession().dataTaskWithRequest(request,completionHandler: { (data, response, error) in
do {
methidを呼び出す私のWebサービスである。しかし、この条件は満たさないようです。私はそのエラーメッセージをprenting見ることができます。
guard let endpoint = NSURL(string: fullURL) else {
print("Error creating endpoint")
return
}
しかし、上記のURLをブラウザに入力すると、サービス応答が表示されます。この理由は何ですか?私を助けてください。 ありがとう
ありがとうございます。それは働いた:) – user1960169
ウェルカム....... :) –