I'm working on a large project. Several times now I've found after adding new code with associated log commands to debug it the application starts getting messages like this to syslog:
*** -[AScriptName someMethod:parm2:parm3:]: unrecognized selector sent to object <AScriptName @0x200545b00: OSAID(514)>
The selector is aways a valid one for a handler in the same script and which was working fine before the bug starts happening. And the selector is either the same one for the function that is executing or another handler in the same script which isn't even called by the handler getting the exception.
This type of error is repeatable, and the method listed will be the same. But after a code change a different selector for a handler in the same script may start repeatedly showing up.
Most of my handlers have a try block surrounding the handler code. Each time the problem log message appears the 'on error' correctly runs. My 'on error' handlers include the errorMsg parameter which is always the same selector error message that was just logged.
The unrecognized selector problem will mysteriously go away once I spend considerable time adding log statements and rearranging code to try and track what is going on. And once fixed, if I revert back to any of the past failed attempts the bug reappears and reporting the same method selector as was reported before.
I've only tried disabling garbage collection for two of the times the problem came up, but both times the problem went away until I reenabled GC.
current application's NSGarbageCollector's defaultCollector()'s disable()
Finally I'm starting to see another pattern, besides stopping GC, that seems to bypass this problem - the elimination of the & operator with string operands from the log command. Here's the latest example where I bypassed this problem:
_____ Original Code
set startHour to startComponent's hour() as integer
set endHour to endComponent's hour() as integer
log "GMT startHour " & startHour & ", endHour " & endHour
_____ Code That Works
set startHour to startComponent's hour() as integer
set endHour to endComponent's hour() as integer
log "GMT startHour"
log startHour
log ", endHour"
log endHour