Xcode 7 Err "Editor placeholder in source code"
Asked Answered
G

7

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

Goodsized answered 12/8, 2015 at 14:35 Comment(1)
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 incorrectGoodsized
S
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)
Servomechanism answered 26/10, 2015 at 17:4 Comment(0)
P
3

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

Perhaps answered 21/2, 2017 at 16:57 Comment(0)
C
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.

Cosmism answered 5/5, 2016 at 1:44 Comment(0)
C
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
Comply answered 3/6, 2016 at 13:35 Comment(0)
A
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:")

Agnosia answered 6/10, 2016 at 8:19 Comment(0)
F
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")
Flatting answered 25/1, 2017 at 12:27 Comment(0)
V
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)
Vertebrate answered 24/3, 2017 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.