Error Editor placeholder in source file in setTitle call

In this fiunction I am trying to change the title of a button when the button is pressed.


@IBAction func changeUnits(_ sender: Any)

{

metricUnits = !metricUnits

let cState = UIControlState.normal;

if (metricUnits)

{

unitsButton.setTitle("Metric", for: cState) // this line has error : Editor placeholder in source file

}

else

{

unitsButton.setTitle("English", for: cState) // this line has error : Editor placeholder in source file

}

}


What am I doing wrong? Is this a bug?


Thx in advance

An editor placeholder is a token that's inserted into your source, typically when you use autocomplete and there are parameters whose actual values you need to supply. You should be able to see the placeholders as a colored rounded-corner rectangle around a piece of the source line.


If you can't see it, then it sounds like a cosmetic bug where a placeholder has been reduced to 0 size, or has somehow turned invisible. You can try retyping the line, or cut it and paste it with Command-Option-Shift-V ("paste and preserve formatting") to see if that helps. Or paste it into a text view or text field somewhere, and see if there are extraneous characters.

If you can't see it, then it sounds like a cosmetic bug where a placeholder has been reduced to 0 size, or has somehow turned invisible.

Another possibility is a ‘ghost’ error. I’ve seen situations where Xcode will keep displaying an old error long after you’ve fixed the underlying problem. Closing and re-opening the project usually clears those.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I fixed the problem by copying the code in question into a TextEdit window. I then checked for extraneous characters. There were none.

I then removed the old text from my Xcode window and copyed and pasted the TextEdit code back into the Xcode window.

This removed the errors

Yes, Xcode loves to hold on to indexed data that in turn acts as a trigger for invalid errors. Next time, use Xcode's Product menu, then, with the option key pressed, select 'Clean Build Folder' to force it to let go of such cruft. Confirm no errors in the navigator and go again.

Error Editor placeholder in source file in setTitle call
 
 
Q