"NSReceiverEvaluationScriptError: 3 (1)" Error

I know lots of people get the dreaded “NSReceiverEvaluationScriptError: 3 (1)” error (mostly arbitrarily) but I was wondering if anyone had a definitive solution to trap it. I’ve scoured the Apple mailing lists and while there are many mentions of this error, no one has provided a foolproof way to avoid it.

The error doesn’t appear all the time from one build to the next or even within the same build (e.g., I can build and run from AS Studio and not get the error but running the same app on its own–still in the build directory–from the Finder results in the error and vice versa (I get the error in AS Studio but not from the Finder)). This error is related to calling an object in the NIB that for some reason, AS can’t identify. Some have suggested it has to do with combo-NIBs (compatible with 10.1 & 10.2) but saving as one or the other doesn’t help. This error is holding me up from releasing an application and trying my sanity.

Any help would be greatly appreciated.

Jon

This is from a while ago, so the details of what error code and what i did can’t be gauranteed.

The behaviour you describe is what triggered my memory not the error code.

The problem occured when I had been in a tell block of another application, and then after the end tell statement accesing elements in the user interface doing things like


set the contents of text field "text field" of window "main" to "dodgy text"

would sometime produce the error and other times would work perfectly. This was really difficult to track down because I had trouble predicting when the error was going to occur.

I got rid of the errors by wrapping the commands in a tell window block, as in:


tell window "main"
set the contents of text field "text field" to "dodgy text"
end tell

I hth

Kevin

Kevin,

Thanks for the tip. Unfortunately, I’m seeing this behavior when I assign an AS name to an NSMenu in IB and then link it to an “Awake From NIB” action just to identify the menu. IFor instance, I have a menu item named “my_menu” and I use this code:

If I don’t do it this way, sometimes AS can’t identify the object using something like “set my_menu to item 1 of (every item whose name = “my_menu”)”. I’m not sure how to wrap this in a tell block because the container is the application. Adding “tell me to set my_menu to the_object” or “tell me to set my_menu to item 1 of (every item whose name = “my_menu”)” doesn’t help.

Thanks again,
Jon

Jon,

This is really clutching at straws but have you tried the following:


    set object_name to (the name of the_object) as string 

instead of:


          set object_name to name of the_object as string

I have found the use of the brackets and the keyword “the” to be important at strange times.

Kevin

Kevin,

I just tried the tip of adding “the” and parens and still got the error. Still searching…

Thanks so much for the tips.

Jon