I can get a string generated by an internal method into an NSString object easily enough and use the NSString object easily:
tell class "NSString" of current application
set theString to stringWithString_(my get_f_as_alias(thePath) as text)
end tell
set theList to theString's componentsSeparatedByString_(":")
I’ve tried everything I can think of to get a string constant into an NSString object but without success. e.g.:
tell class "NSString" of current application
set aString to initWithString_(PathList as text)
end tell
I get an error message on the console:
+[NSString initWithString:]: unrecognized selector sent to class 0x7fff70791258
Just use stringWithString_ again.
It must seem odd but stringWithString_ was the first method I tried. It worked in the first example I sent in the posting but didn’t work in the latter. Now it does?!
I’m stuck in the next step of my process “ appending some text to the NSString object. I tried
tell class "NSString" of current application
set aString to stringWithString_(":Volumes:")
end tell
set aString to my aString's stringByAppendingString_(a reference to anString)
that was a disaster. I tried using the NSMutableString’s appendString_ to no avail:
tell class "NSMutableString" of current application
set aString to stringWithString_(":Volumes:")
end tell
my aString's appendString_("Twaddle:")
aString was unchanged after this last step. Any ideas?
Change this:
my aString's appendString_("Twaddle:")
to this:
aString's appendString_("Twaddle:")
If you look in the console it will tell you that “aString” is not key-value coding compliant.
This is because you do not have “aString” setup as a property but a local variable.
Thanks Craig. I couldn’t decode that piece of jargon in the console. Now I know.