[ios] 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"

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

I changed the Node Class around to:

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!]()
     }

}

This Error happens 5 times throughout the code that I have built so far. Also this question has been asked, but not answered.

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.

This question is related to ios swift class

The answer is


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.


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.


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() {

}

After Command + Shift + B, the project works fine.


Go to Product > Clean Build Folder


Clean Build folder + Build

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


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to swift

Make a VStack fill the width of the screen in SwiftUI Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code in Xcode 10 Convert Json string to Json object in Swift 4 iOS Swift - Get the Current Local Time and Date Timestamp Xcode 9 Swift Language Version (SWIFT_VERSION) How do I use Safe Area Layout programmatically? How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator Safe Area of Xcode 9 The use of Swift 3 @objc inference in Swift 4 mode is deprecated?

Examples related to class

String method cannot be found in a main class method Class constructor type in typescript? ReactJS - Call One Component Method From Another Component How do I declare a model class in my Angular 2 component using TypeScript? When to use Interface and Model in TypeScript / Angular Swift Error: Editor placeholder in source file Declaring static constants in ES6 classes? Creating a static class with no instances In R, dealing with Error: ggplot2 doesn't know how to deal with data of class numeric Static vs class functions/variables in Swift classes?