Swift错误:源文件中的编辑器占位符 [英] Swift Error: Editor placeholder in source file
问题描述
您好,我正在实现图形数据结构。当我尝试构建应用程序时,出现错误源文件中的编辑器占位符
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"
完整图形实现是从WayneBishop的GitHub此处 https://github.com/waynewbishop/SwiftStructures
The full graph implementation was pulled from WayneBishop's GitHub from here https://github.com/waynewbishop/SwiftStructures
class Path {
var total: Int!
var destination: Node
var previous: Path!
init(){
//Error happens on next line
destination = Node(key: String?, neighbors: [Edge!], visited: Bool, lat: Double, long: Double)
}
}
我更改了 Node
围绕以下类:
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!]()
}
}
此错误在我到目前为止构建的代码中发生了5次。
This Error happens 5 times throughout the code that I have built so far. Also this question has been asked, but not answered.
我认为该错误可能是由于我对 init()$所做的更改所致。
Node
类中的c $ c>。在进行更改之前,它只是 init()
。如果是这样,如何将对象添加到类中?如果我的编程术语不正确,请原谅我,因为我是OOP的新手。
I think the error may be due to my changes to the init()
in the Node
class. Prior to my changes it was just init()
. If it is, how can I add objects to the class? Pardon me if I am not correct in my programming terminology, as I am relatively new to OOP.
推荐答案
您有这个
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)
}
}
这篇关于Swift错误:源文件中的编辑器占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!