I want to make a windowless application. The problem is that I’m using a framework that shows some alert boxes sometimes, and I’m not able to suppress them (at least not without a crash).
I’ve set LSBackgroundOnly to 1 (in the info.plist app file), but this doesn’t seem to work. Any chance I’m missing something here (maybe some other settings that I need to set)?
I’ve also tried creating a category for NSWindow:
-
Overwritten
allocandallocWithZone:so that no window gets created. This works on some situations, but starting a modal session throws exception (because sending a nil parameter tobeginModalSessionForWindow:). -
Tried overwriting NSApplication’s
beginModalSessionForWindow:and returned nil everytime, but this leads to EXC_BADACCESS somewhere in the framework (runModalSession:andendModalSession:were also overwritten, but the crash is before any of them being called).
Any other ideas will be welcome.
In case it helps, the framework that I’m using is Twain.Framework, so if instead anyone knows a way to block all UI from twain (this includes error alerts shown when a device is not connected) it would be great if you share.
I managed to make it ‘windowless’ (some windows are still shown, but at least they’re not visible, and they’re automatically closed). I only handled modal windows, since these where shown in my situation.
I made a category for
NSWindow, so that all windows are invisible, and can’t become key or main windows:Subclassed
NSApplication:However, this didn’t help much. In case of
runModalForWindow:everything was good, since the owner of the window received a response. In case ofbeginModalSessionForWindow:the application got stuck, most probably because the window’s owner was waiting for a specific event (e.g. button click) which it never received.