8

I have just started trying to learn Swift, but one error keeps cropping up time and again and I can not find out why - "Editor placeholder in source code". What could be causing this (I am unable to post a picture of the code as I am a new member).

Thanks

Richard
  • 91
  • 1
  • 1
  • 3
  • Strange, I found the err when I tried to copy and paste the code on here. The code Xcode gave me was btnButton.setTitle(title: String?, forState: UIControlState). But just by removing the space between ":" and "UIControlState", then adding () afterwards cleared the error. So the auto text is incorrect – Richard Aug 12 '15 at 14:57

7 Answers7

5

It happened to me just now, but the reason was pretty straightforward once I looked at the code. I was using the autofill class as the param for a function. Ergot "place holder"

//Leaving the auto-completed signature gave the error
myclass.myFunction(myParam: UIControl)

//removing the auto complete params and using a real one cleared error
myclass.myFunction(myUIControl)
Sean
  • 2,412
  • 3
  • 25
  • 31
3

For me it helped to fix this (my code is correct) just applying Xcode - Product - Clean (Shift+Cmd+K)

Kiryl Ivanou
  • 1,015
  • 2
  • 12
  • 22
2

Just happened to me using xcode 7.3.1 on existing code "that was fine yesterday". I couldn't see anything wrong, so I re-typed (the offending line to see where it went wrong) on the line above and deleted the original and error went away. A git diff shows no change.

nikrb
  • 153
  • 3
  • 10
0

It's happened to me, but I had forgot to define a part of code:

When I get the error:

let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeTableViewCell",
    forIndexPath: NSIndexPath) as! EmployeeTableViewCell

After I fixed:

let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeTableViewCell",
    forIndexPath: indexPath) as! EmployeeTableViewCell
Draken
  • 3,134
  • 13
  • 34
  • 54
0

I had the same problem, it was caused by a double space (Xcode 8.1 beta)

before:

let cell = UITableViewCell(style:  UITableViewCellStyle.default, reuseIdentifier: "Cell")

after (working!):

let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")

(the 2 spaces are after "style:")

0

I've had this issue while doing a Udemy Course that didn't update the curricula with the new Swift 3 info. At least that's what I'm guessing caused the issue that kep on giving me this error.

Old broken code:

let cell = UITableViewCell(style: UITableViewCellStyle, reuseIdentifier: "Cell")

New, working code

let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
lorddarq
  • 685
  • 1
  • 10
  • 17
0

I had this issue when I was doing the swift for beginner practice from Udacity.com. The reason I found out later is because Xcode will put the type of the variable such as int or Bool as a placeholder and you have to replace it with the real value yourself.

func screenVIP(age: Int, onGuestList: Bool, knowsTheOwner: Bool) {

At the end, you should replace it with given values like the following:

screenVIP(age: age, onGuestList: onGuestList, knowsTheOwner: knowsTheOwner)
Jack Du
  • 13
  • 5