Button click not working in child window for Mac OS application using swift 4.

Hi there, i am developing a mac os application, actually i am facing problem in the child window, the button click event is not working in the child window even if i have done everything correctly. The buttons in parent window (Window displayed when application starts) are working fine, when i go to another window by clicking the sign in button the buttons in that second window is not working. Can anyone help me to solve this please.


I am using Xcode9, swift4.

Accepted Reply

Actually i solved the problem, and the problem was in the object creation of that second window. I was creating the object within the function. When i created the object globaly rather than local it worked.


It was like


func example(){

let dashboard = Dashboard()

self.dashboard.showWindow(nil)

}

now i created the object outside the function in global and it worked.

Replies

when i go to another window by clicking the sign in button

What is the "sign in" button ? How do you connect to the second window (segue ?)

How did you create the buttons in second window ? In IB ?


Could you show the code ?

Actually i solved the problem, and the problem was in the object creation of that second window. I was creating the object within the function. When i created the object globaly rather than local it worked.


It was like


func example(){

let dashboard = Dashboard()

self.dashboard.showWindow(nil)

}

now i created the object outside the function in global and it worked.

Good for you and thanks for feedback.


But next time, if you want help, post the code as requested.


It is useless to state " i have done everything correctly." (which was not the case) and much better to let other see what you've done.


Anyway, wish you good continuation.

I will keep that in mind to post my code too 🙂, i have updated my answer with code. Thank you buddy.