user8674636
user8674636

Reputation:

Why is involving a special character from another language creating a crash when I try to call api in iOS SWIFT?

This is the culprit string and paramter name=solsssㅗ

 Alamofire.request(todoEndpoint)
            .responseJSON { response in
                // check for errors
                guard response.result.error == nil else {
                    // got an error in getting the data, need to handle it
                    print("error calling GET on \(todoEndpoint)")
                    print(response.result.error!)
                    DispatchQueue.main.async
                        {
                            self.activityView.isHidden = true
                            self.activityView.stopAnimating()
                    }
                    return
                }

So I get error in URL always as invalid. If I use it without any special character it works fine.

Upvotes: 0

Views: 314

Answers (1)

shivi_shub
shivi_shub

Reputation: 1058

You can try this with String url -

let urlWithSpecialCharacter = url.addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed)

Upvotes: 1

Related Questions