Xcode 7 Err “Editor placeholder in source code”

2019-06-16 12:47发布

问题:

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

回答1:

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)


回答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.



回答3:

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



回答4:

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


回答5:

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:")



回答6:

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")


回答7:

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)