iOS Development

ios – Lacking argument for parameter coder in name

Spread the love


I’m making an attempt to construct and it received’t let me, I’ve adopted different recommendation on stack overflow to initialize my variables however nonetheless getting this error. I’m making an attempt to construct a view programmatically.

class PropertyViewController: UIViewController {
    
    personal var valueLabel = UILabel()
    personal (set) var home: Home
    
    init(
        valueLabel: UILabel,
        home: Home
    
    ) {
        self.valueLabel = valueLabel
        self.home = home
        tremendous.init(nibName: nil, bundle: nil)
 
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been carried out")
    }
    
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        // Do any extra setup after loading the view.
        self.view.backgroundColor = .crimson
        valueLabel.translatesAutoresizingMaskIntoConstraints = false
        
        view.addSubview(valueLabel)
        setUpLabel()
        setUpConstraints()
        
        
    }
    
    func setUpLabel() {
        
        valueLabel.textual content = "homes.postcode"
        valueLabel.textColor = .black
    }
    
    
    
    func setUpConstraints() {
        valueLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
        valueLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    }
}

Scene delegate

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, choices connectionOptions: UIScene.ConnectionOptions) {
    // Use this methodology to optionally configure and fix the UIWindow `window` to the supplied UIWindowScene `scene`.
    // If utilizing a storyboard, the `window` property will routinely be initialized and hooked up to the scene.
    // This delegate doesn't suggest the connecting scene or session are new (see `utility:configurationForConnectingSceneSession` as an alternative).
    guard let scene = (scene as? UIWindowScene) else { return }
    let window = UIWindow(windowScene: scene)
    window.rootViewController = PropertyViewController()
    window.makeKeyAndVisible()
  }

I’ve tried to initialize the variables in my class, calling my view controller immediately (though I don’t have a xib, and make home non-obligatory. Nonetheless I don’t need to do this!

Leave a Reply

Your email address will not be published. Required fields are marked *