ios – Call to mainActor errors in Xcode


I have the following code

func checkLoggedIn(completion: @escaping (_ isLoggedIn:Bool) -> Void) {
    let token = self.getUserToken()
    if (token.count < 1) {
        completion(false)
    } else {
        APICaller.sharedInstance.performCallToEndpoint("/user/session", using: "GET", body: nil) { (error, serverError, response) -> () in
            if let response = response {
                self.setUserToken(response);
                completion(true)
            } else {
                completion(false)
            }
        }
    }

On line setUserToken, when I try to build I get the error Call to main actor-isolated instance method 'setUserToken' in a synchronous nonisolated context

I just upgraded to the newest version of xcode. How can I avoid these new main actor errors?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img