Swift Editor Placeholder in Source File

Swift Error: Editor placeholder in source file

you had this

destination = Node(key: String?, neighbors: [Edge!], visited: Bool, lat: Double, long: Double)

which was place holder text above you need to insert some values

class Edge{

}

public class Node{

var key: String?
var neighbors: [Edge]
var visited: Bool = false
var lat: Double
var long: Double

init(key: String?, neighbors: [Edge], visited: Bool, lat: Double, long: Double) {
self.neighbors = [Edge]()
self.key = key
self.visited = visited
self.lat = lat
self.long = long
}

}

class Path {

var total: Int!
var destination: Node
var previous: Path!

init(){
destination = Node(key: "", neighbors: [], visited: true, lat: 12.2, long: 22.2)
}
}

How can I fix Editor placeholder in source file ?

Struct CircleView has following initializer:

init(_ imageName: String) {
self.imageName = imageName
}

So, you have to provide imageName of type String while creating new CircleView struct.

CircleView("myImage")

You can always check for all available initializers and their parameter names after pointing carriage into the () and clicking Esc button
Sample Image

Swift Editor Placeholder in source file

I found the same question many times on SO. But none of them gave the answer I was looking for.

You get the Placeholder in source file when you have one of these (where it says "String" with a blue background) in your code.

Image

A placeholder is for us programmers. It says "here should be a value of the type String". You can click on it and start typing, to simply replace it with for example a variable name. You can also press tab to automatically select the next placeholder. This is very useful when you are calling a function with multiple parameters (and therefore multiple placeholders).

A placeholder is actually just normal text (<#T##Strign#>), but XCode "translates" it to look like how it does.

In your case the error is on line three.

...withReuseIdentifier: "Cell", for: <#T##IndexPath#>) as! CustomBrandCell

As you can see <#T##IndexPath#> is a placeholder as normal text as I mentioned earlier. You probably want this to be indexPath

Swift - Editor placeholder in source file

This code is wrong:

fields[index].addGestureRecognizer(gestureRecognizer:  UIGestureRecognizer)

When you are calling a method, you supply an argument value: you do not supply a type describing the required parameters. You want to say this:

fields[index].addGestureRecognizer(gestureRecognizer)

An editor placeholder is a solid rounded rectangle with text in it, inserted through code completion. It might look like this:

Sample Image

or this:

Sample Image

You need to look for that sort of thing in your code and replace it with actual text (or delete it).

Editor placeholder in source file swift

You need to write it like this:

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MenuCollectionViewCell", for: indexPath) as! MenuCollectionViewCell
return cell
}


Related Topics



Leave a reply



Submit