NSString to AppleScript string


I’m rather new to this. I’m using XCode Version 3.2.5 and the cocoa documentation in XCode → Help → Developer Documentation (option-command-?).

The following snippet:

	set SharedCalendarStore to defaultCalendarStore of ¬
		class "CalCalendarStore" of current application
	log "description of SharedCalendarStore=" & description of SharedCalendarStore
	set MyCalendars to calendars of SharedCalendarStore
	log "count of MyCalendars=" & (count of MyCalendars)
	log "description of MyCalendars=" & (description of MyCalendars)

produces the following log:

description of SharedCalendarStore=<CalCalendarStore: 0x2006d61e0>
count of MyCalendars=12
Can’t make description of «class ocid» id «data kptr00000000A0A3620002000000» into type Unicode text.

MyCalendars is (I think) an NSArray whose ‘description’ method is supposed to produce an NSString instance “that represents the contents of the array, formatted as a property list.” I suppose that the problem here is that the NSString instance can’t be coerced to an AppleScript string, even though a similar NSString instance three lines above seemed to work. (Adding ‘as text’ or ‘as string’ didn’t help.)

Q1. Is my analysis correct?
Q2. If so, is there another way to coerce an NSString to an AppleScript string?
Q3. I have gotten this far without using “property” statements. Are they necessary?

I’d appreciate any comments.


The problem is not the string not being coerced – the result is an NSArray of strings, you have to coerce the array to an AS list first:

 log "description of MyCalendars=" & (description of MyCalendars as list)


Thanks, Ric!

That works!