iOS Development

ios – Name to major actor-isolated occasion technique ‘setUserToken’ in a synchronous nonisolated context

Spread the love


I’ve the next code

   APICaller.sharedInstance.performCallToEndpoint("/consumer/session", utilizing: "GET", physique: nil) { (error, serverError, response) -> () in
            if let response = response {
                self.setUserToken(response);
                completion(true)
            } else {
                completion(false)
            }
        }

The place I am calling setUserToken I get the error Name to major actor-isolated occasion technique 'setUserToken' in a synchronous nonisolated context

Can somebody please assist?

This is the code for performCallToEndpoint

APICaller {

    func performCallToEndpoint(_ endpoint:String, utilizing technique:String, physique: [String: Any]?, completion: @escaping (_ error:Error?, _ serverError: String?, _ response: NSDictionary?) -> Void) {
        
    
        let request = createURLRequest(toEndpoint: endpoint, utilizing:technique, physique: physique)
        
        URLSession.shared.dataTask(with: request) { information, response, error in
            guard error == nil else {
                print("Error: error calling POST")
                completion(error, nil, nil)
                return
            }
            guard let information = information else {
                print("Error: Didn't obtain information")
                completion(nil, nil, nil)
                return
            }
            guard let response = response as? HTTPURLResponse, (200 ..< 299) ~= response.statusCode else {
                print("Error: HTTP request failed")
                completion(nil, nil, nil)
                return
            }
            do {
                guard let jsonObject = strive JSONSerialization.jsonObject(with: information, choices: []) as? NSDictionary else {
                    return
                }
    
                let responseError = jsonObject["error"] as? String
                    
                if responseError?.rely != nil {
                    completion(nil, responseError, nil)
                } else {
                    if (jsonObject["result"] == nil) {
                        completion(nil, nil, jsonObject as! NSDictionary)
                    } else {
                        completion(nil, nil, jsonObject["result"] as! NSDictionary)
                    }
                }
            } catch {
                print("Error: Making an attempt to transform JSON information to string")
                return
            }
        }.resume()
    }

}

Can somebody assist me perceive what I am doing mistaken? I am not in a position to construct my swift mission after upgrading to the most recent model of xcode. Thanks!

2 thoughts on “ios – Name to major actor-isolated occasion technique ‘setUserToken’ in a synchronous nonisolated context

  1. I loved as much as you will receive carried out right here The sketch is attractive your authored material stylish nonetheless you command get got an impatience over that you wish be delivering the following unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike

Leave a Reply

Your email address will not be published. Required fields are marked *