2

In one of my Applications I've added a few new properties to the document class of the Standard AppleScript suite. Some of these properties have the type text, others have the type boolean. I've written a "sdef" file and added if to the resources of my App.

But when I launch the App, there are messages in the Console like this:

.sdef warning for type 'text' attribute 'title' of class 'window' in suite 'Standard Suite': AppleScript name references may not work for this property because its type is not NSString-derived.

And when I actually try to get the value from such a new property with type text from within an AppleScript, it will fail. The correct method within my App is called, and it returns the correct value as NSString, but the AppleScript returns with an error. There's a message in the Console again:

Error while returning the result of a script command: the result object... "the requested NSString value" ...could not be converted to an Apple event descriptor of type 'text'. This instance of the class '__NSCFString' returned nil when sent -objectSpecifier (is it not overridden?) and there is no coercible type declared for the scripting class 'text'.

Which probably means that it was not possible to convert the Cocoa NSString object into an AppleScript text object.

When I try to get the value from one of the new boolean properties, it works just fine.

What exactly do I need to do to convert a NSString object into an AppleScript text object?

2
  • 1
    Without seeing any code it's difficult to diagnose. My initial questions would be 1) is the memory being released properly and 2) are you creating the NSString properly? Commented Dec 21, 2011 at 21:45
  • Could you please post some code? Commented Apr 13, 2012 at 5:04

1 Answer 1

0

I suspect you need to coerce the text parameter into a NSString.

I.e

Set sometextString to current application's NSString's stringwithTring:atext

Use it in your method

And to return it you do.

Return sometextString as text
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.