Editor placeholder in source file Xcode 8

Hi everyone. I'm new to using Xcode and this is my first time coding. I'm currently following some tutorials that require this coding to create a rectangle:


let canvas = UIView(frame: CGRectMake(0, 0, 200, 200)). I know that CGRectMake was removed from xcode so I changed my code to


let canvas = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))


I'm getting a swift compiler warning of 'editor placeholder in source file'. Can someone tell me how to fix this and why i'm getting it?

Accepted Reply

When you insert code via autocompletion (or via a code snippet, sometimes), there may be placeholders — blue rectangles that describe what you should put there instead. You can click on a placeholder to select it, then type your actual code.


For example (I'm guessing) when you typed "UIView(", you inserted a complete call, but with a "CGRect" placeholder where the rect was supposed to go. If you put the rect parameters after the placeholder without replacing it, you'd get this error message. You should have replaced the placeholder, not used it as code.


If that's what happened, you don't have to actually retype it in this case. If you double-click on a placeholder (or select it and press Enter), it will change to regular text.

Replies

When you insert code via autocompletion (or via a code snippet, sometimes), there may be placeholders — blue rectangles that describe what you should put there instead. You can click on a placeholder to select it, then type your actual code.


For example (I'm guessing) when you typed "UIView(", you inserted a complete call, but with a "CGRect" placeholder where the rect was supposed to go. If you put the rect parameters after the placeholder without replacing it, you'd get this error message. You should have replaced the placeholder, not used it as code.


If that's what happened, you don't have to actually retype it in this case. If you double-click on a placeholder (or select it and press Enter), it will change to regular text.

That's exactly what I did by the looks of it. I've double-clicked and its changed and given me the rectangle I needed. Thanks!

Command + Shift + b
It works perfectly... I have already done this for tableView
  • Thank you, Anam098. I was having a similar issue, and the "Command + Shift + b" cleared it perfectly!

Add a Comment
In addition to the solution offered by Quincey Morris, if you can't find said placeholder, try closing and reopening your project, or even Xcode.

Thank you @Anam098 it worked.