I get NSCFString, but I want NSString !

Hi,

I want to “play” with dictionaries and anagrams, with ApplescriptObjC.

I managed to save a file that can be read as an array.
But each object of the array happens to be a NSCFString ; following Shane Stanley’s books, I understand that I want to have NSString because NSCFString are not suitable for ASOC.

How can I get NSStrings ?

Here is the code to get the array :

set monTableau to current application's NSArray's arrayWithContentsOfFile:"/Users/nicolas/Desktop/DicoTest.rtf"

The file DicoTest.rtf includes :

<?xml version="1.0" encoding="UTF-8"?> aa aah aahed aahing aahs aal aalii aaliis aals aardvark aardvarks aardwolf aardwolves aargh

Thanks for your help !
Nicolas

I assume you mean __NSCFString, and they’re fine – you’ll even find the class mentioned in the book. It’s a subclass of NSString.

NSString is what’s known as a class cluster: when you ask for a string, what you get can be an instance of any of a range of subclasses.

The one you can’t generally deal with is a CFStringRef.

If that’s really an rtf file, you need to read it differently. But it looks like it’s actually a property list file, in which case the code should be fine.

Thanks for the reply.

I managed indeed to do what I wanted with the NSCFString (I was trying to use a method that was not working for NSString either…)

Best regards
Nicolas