While working on my project to get the name and class of every named object in an ASS app. I have come upon a problem that I don’t know how to solve:
...
set theViews to every view of every window of me
set thePairs to CreateNIBPairs(theViews)
....
to CreateNIBPairs(CNPViews)
set CNPPairs to {}
repeat with x from 1 to count of CNPViews
set cnpView to item x of CNPViews
repeat with y from 1 to count of cnpView
try
set cnpName to name of item y of cnpView --> 1
on error errNum
set cnpName to ""
end try
if cnpName is not "" then --> 2
...
...
The problem occurs when an item without a name is encountered. The “name” property will contain missing value. When the line of code indicated by arrow #1 is executed, no error is generated and cnpName is no longer defined, creating an error on the line indicated by arrow #2. My thought is that if no name was present, an error WOULD be generated and cnpName should be set to “”. The “on error” portion (errNum included in a debugging effort) of the script is never encountered.
Any help will be grately appreciated,
Brad Bumgarner, CTA
OS X 10.4.2
Xcode 2.1