Resolve "The compiler is unable to type-check this expression in reasonable time..." error with UIAlertAction

Viewed 51

In short, I have this line:

let saveAction = UIAlertAction(title: "OK", style: .default) {_ in

Now Xcode says that there is the error of "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions." This error has never happened on lines like this; they are in many projects of mine.

Now, the question is how do I go about "splitting" up this line into separate lines?

I have tried

saveAction.Style = .default etc...

But I cannot access the title of the AlertAction, nor add handlers.

There is the code inside the block:

let inputName = alertController.textFields![0].text

//print(inputName)

//finalVal is a String
//inputName is a String

recievedName = inputName ?? ""

if(players == "")
{
             
       UserDefaults.standard.set(String(recievedName) + ": " + finalVal + "%", forKey: playerSave)

} else {
               
        UserDefaults.standard.set(playerSave + "\n" + String(recievedName) + ": " + finalVal + "%", forKey: playerSave)
            
}


UserDefaults.standard.synchronize()
0 Answers
Related