Friday, February 9, 2024
HomeiOS Developmentios - Lacking argument for parameter coder in name

ios – Lacking argument for parameter coder in name


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 applied")
    }
    
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        // Do any further setup after loading the view.
        self.view.backgroundColor = .purple
        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 technique to optionally configure and fix the UIWindow `window` to the supplied UIWindowScene `scene`.
    // If utilizing a storyboard, the `window` property will mechanically be initialized and connected to the scene.
    // This delegate doesn't suggest the connecting scene or session are new (see `software:configurationForConnectingSceneSession` as a substitute).
    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 (although I don’t have a xib, and make home non-compulsory. Nevertheless I don’t need to do this!



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments