Swift Error: Editor placeholder in source file

后端 未结 7 673
长发绾君心
长发绾君心 2020-12-06 03:39

Hello I am implementing a graph data structure. When I try to build the application the I get the error \"Editor placeholder in source file\"

The full graph implemen

相关标签:
7条回答
  • 2020-12-06 04:18

    Error is straight forward and its because of wrong placeholders you have used in function call. Inside init you are not passing any parameters to your function. It should be this way

    destination = Node("some key", neighbors: [edge1 , edge2], visited: true, lat: 23.45, long: 45.67) // fill up with your dummy values
    

    Or you can just initialise with default method

    destination = Node()
    

    UPDATE

    Add empty initialiser in your Node class

    init() {
    
    }
    
    0 讨论(0)
  • 2020-12-06 04:20

    Clean Build folder + Build

    will clear any error you may have even after fixing your code.

    0 讨论(0)
  • 2020-12-06 04:22

    Go to Product > Clean Build Folder

    0 讨论(0)
  • 2020-12-06 04:28

    Sometimes, XCode does not forget the line which had an "Editor Placeholder" even if you have replaced it with a value. Cut the portion of the code where XCode is complaining and paste the code back to the same place to make the error message go away. This worked for me.

    0 讨论(0)
  • 2020-12-06 04:31

    If you have this error while you create segues with the view controllers not with the UI elements you have to change sender: Any? to this

    @IBAction func backButtonPressed(_ sender: Any) {
            performSegue(withIdentifier: "goToMainScreen", sender: self)
    
        }
    

    It will work.

    0 讨论(0)
  • 2020-12-06 04:37

    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)
      }
    }
    
    0 讨论(0)
提交回复
热议问题