A Bit of RB Trivia: The Answer
April 4th, 2008 by Joe RanieriSo, the question I asked last time was this:
Name a situation when the global App object is nil (while executing user code).
The two answers that were submitted and correct are:
- Charles Yeomans pointed out that properties in modules are destructed after the global App object has been set to nil. Example project.
- Ben Johnson went the other way around and noticed that the global App object is nil in your Application subclass’ constructor. Example project.
However, neither of these were the answer I was looking for. What happens is that REALbasic does a bit of initialization before setting the global App object. Part of that initialization is setting up the menubar, which entails creating the MenuItems. If you have a subclass of MenuItem in that menubar, REALbasic invokes your constructor, and at that point, the global App object is nil. Example project.
Congratulations to Charles and Ben, both of which will be receiving a free license to CalendarKit.