3 ms·
I knew this was possible, but I had never actually seen it implemented before. And to think, the project is over 10 years old! When I first started programming
by ryandrake 3y ago
I knew this was possible, but I had never actually seen it implemented before. And to think, the project is over 10 years old!
When I first started programming Cocoa, I was always kind of miffed that the happy-path was: "Use Objective-C and main() should just hand-off the reigns to NSApplicationMain()". Kind of like the happy-path on Windows is "WinMain plus a bunch of boilerplate crud".
It's always felt somehow vaguely "correct" to have main() be your actual application entry point and have it manage whatever main loop you need yourself. I see that this project doesn't actually quite get there either. It's the same kind of voodoo: boilerplate code, and then cmacs_void_msgSend(NSApp, sel_getUid("run")); hands over the reigns.
- williamcotton 3y agoIt has to hand over the reigns to the Objective-C runtime to allow for all the messages being passed between objects. I’m not sure you want to spend your time rewriting what NSApp is doing!
- saagarjha 3y agoThe runtime knows how to do that already. -[NSApplication run] sets up the runloop to drain events among other things.
- astrange 3y agoWhy would you want to manage your own runloop? It's both not interesting and possible to get wrong.
- adastra22 3y agoSometimes there are conflicting things you need to do in the same main thread.
- billforsternz 3y agoI agree. I recall the Windows API and the official Hello World. I'm sure they could have got to the same place in a slightly reorganised way that kept main() as the starting point and interfaced with the event loop and the entire windowing system via some API calls that hid the cruddiest parts of the boilerplate crud (apt phrasing, thank you) away in headers and libraries. Then progressively reveal the details when they're really necessary for more elaborate applications.