The problem is that NSWorkspace.willSleepNotification is not available in Catalyst. It relies on the lower-level IORegisterForSystemPower, but that's in IOKit and all C-based. So I don't know how to get notified of impending sleep in Swift in a Catalyst app.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…