Position from the beginning

How to position the window of the app from the beginning, when the app launches?


This works well if I put in a button:


@IBActionfunc test(_ sender: NSButton) {
     view.window?.setFrame(NSRect(x:0,y:0,width:500,height:500), display: true)
}


But it does not work if I put in the viewDidLoad or ViewDidAppear:


overridefunc viewDidLoad() {
        super.viewDidLoad()

        view.window?.setFrame(NSRect(x:0,y:0,width:500,height:500), display: true)
    }

Replies

Thank you. Can you apply to my case? I cannot put the information on the link in practice

It's going to be in Obj C.


put this in your viewDidLoad:


[self performSelector:@selector(myDelayedStuff) withObject:nil afterDelay:0.3];


Then create a short function:


-(void)myDelayedStuff {
     // put your setFrame code in here.
}