I've finally found the cause of mysterious program errors vexing the development of a rather large ASOC project. Typically the errors were syslog lines of:
-[CalendarBug currentCalendar]: unrecognized selector sent to object <CalendarBug @0x200668be0: OSAID(7)>
where the selector was a valid handler in the same script and appeared unrelated to the then currently executing handler. At that point any further code modifications, even trivial ones, could make the program EXC_BAD_ACCESS fault with no log messages issued, or fault in a later executed portion of the application, or start running correctly again. When a problem occurred it was totally reproducible until the source code was next modified. Then it would either stay the same, go away or get worse.
The problem was my incorrect use of a saved reference as follows: ______ property NSCalendar : class "NSCalendar" property currentCalendar : missing value
on aHandler() set currentCalendar to NSCalendar's currentCalendar() ... set GMTAdjustedDate to currentCalendar()'s dateByAddingComponents_toDate_options_(theComponents, theCalendarDate, 0) -- SHOULD BE: currentCalendar's ______
Perhaps there is a reason why the ASOC runtime needs to try invoking the currentCalendar method on the script class. I would have found this bug right away if the unrecognized selector error had referenced the NSCalendar instance. That logged message is not correct given that the selector is a valid one for a handler in the reported object (my script.)
Another runtime malfunction might be the fact that no error log messages make it out if the program bombs (EXC_BAD_ACCESS.) Perhaps if a program faults too quickly after a log message is emitted (by the runtime in my case) some messages never make it out?
Happy Coding! |