Should i set window.isReleasedWhenClosed to true or leave it to default?

Hi, In mac os swift ui application when i set window.isReleasedWhenClosed and when i close the window the app is getting crashed with exc_bad_access. but when i leave it to default value the app is not crashing. for some windows setting window.isReleasedWhenClosed to true is woking properly when closing the windows. But for some windows it is crashing. If i dont set it to true the window is not removed from NSApplication.shared.windows sometimes. I am confused about setting isReleasedWhenClosed to true

Could someone calrify on this please.

thank in advance.

An EXC_BAD_ACCESS is happening because you're trying to access a resource that no longer exists, so it looks like something in your code is trying to do 'something' with that window after you've told it to be released when it's closed.

You need to debug your code and ensure you're not trying to do anything with released resources.

Accepted Answer

i moved setting window.isReleasedWhenClosed true to OnDisappear and the problems is solved and NSApplication.shared.windows does not retain any windows that are closed. thanks

Should i set window.isReleasedWhenClosed to true or leave it to default?
 
 
Q