• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Another AppleScript-ObjC Dictionary question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Another AppleScript-ObjC Dictionary question


  • Subject: Another AppleScript-ObjC Dictionary question
  • From: Dave <email@hidden>
  • Date: Tue, 15 Mar 2016 15:47:35 +0000

Hi Again,

How do I pass an NSDictionary that is returned from an ApplesScript handler to another handler?

I get an error in setWordStandardDocumentDictionary running this code:

	set myDocumentID to (theStandardDocumentDictionary's objectForKey:"kDocumentID")
	set myStandardPropertyArray to (theStandardDocumentDictionary's allKeys)			—Error Here

error "Can’t get allKeys of «class ocid» id «data optr0000000070A1240080630000»." number -1728 from allKeys of «class ocid» id «data optr0000000070A1240080630000»

statement. Yet the statement before returns what I was expecting?

Thanks for the Help.

All the Best
Dave

-------------

on getWordStandardDocumentDictionaryWithDocumentID:(theDocumentID as string)
	--say "getWordStandardDocumentDictionaryWithDocumentID:" --& theDocumentID

	set myDocument to my getWordDocumentWithDocumentID:(theDocumentID)

	tell application id "com.microsoft.Word"
		set myTranslationDictionary to pWordStandardDocumentPropertiesKeyTranslationDictionary of me

		set myStandardPropertiesDictionary to current application's NSMutableDictionary's alloc()'s init()
		set myStandardPropertyArray to (document properties of myDocument)

		repeat with myStandardProperty in myStandardPropertyArray
			set myPropertyName to the name of myStandardProperty
			set myPropertyValue to the value of myStandardProperty
			if myPropertyValue = missing value then
				set myPropertyValue to ""
			end if

			set myTranslatedPropertyName to (myTranslationDictionary's objectForKey:myPropertyName) as string
			if myTranslatedPropertyName = missing value then next

			(myStandardPropertiesDictionary's setObject:myPropertyValue forKey:myTranslatedPropertyName)
		end repeat

		set kDocumentID of myStandardPropertiesDictionary to theDocumentID
	end tell

	return myStandardPropertiesDictionary
end getWordStandardDocumentDictionaryWithDocumentID:


on setWordStandardDocumentDictionary:(theStandardDocumentDictionary)
	--say "setWordStandardDocumentDictionary:"

	set myDocumentID to (theStandardDocumentDictionary's objectForKey:"kDocumentID")

	log "======" & myDocumentID
	set myStandardPropertyArray to (theStandardDocumentDictionary's allKeys)

	set myDocument to my getWordDocumentWithDocumentID:(myDocumentID)

	tell application id "com.microsoft.Word"
		set myTranslationDictionary to pWordStandardDocumentPropertiesKeyTranslationDictionary of me


		repeat with myPropertyName in myStandardPropertyArray
			set myTranslatedPropertyName to (myTranslationDictionary's objectForKey:myPropertyName) as string
			if myTranslatedPropertyName = missing value then next

			set myPropertyValue to (theStandardDocumentDictionary's objectForKey:myPropertyName)
			if myPropertyValue = missing value then
				set myPropertyValue to ""
			end if

			set the value of (custom document properties of myDocument whose name is myTranslatedPropertyName) to thePropertyValue
		end repeat

		set kDocumentID of myStandardPropertiesDictionary to theDocumentID
	end tell
end setWordStandardDocumentDictionary:

on run

	tell application id "com.microsoft.Word"
		activate
	end tell

	get my setupKeyTranslationDictionary()

	set myDocumentID to my getWordActiveDocumentID()
	set myStandardPropertiesDictionary to my getWordStandardDocumentDictionaryWithDocumentID:(myDocumentID)
	(myStandardPropertiesDictionary's setObject:"Hello Cruel World!" forKey:"kDocumentKeywords")

	get my setWordStandardDocumentDictionary:(myStandardPropertiesDictionary)

	return myStandardPropertiesDictionary
end run


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Another AppleScript-ObjC Dictionary question
      • From: Dave <email@hidden>
  • Prev by Date: Re: question about last used date
  • Next by Date: Re: Another AppleScript-ObjC Dictionary question
  • Previous by thread: Re: Making Managed Object Context available to array controller in Storyboard scene
  • Next by thread: Re: Another AppleScript-ObjC Dictionary question
  • Index(es):
    • Date
    • Thread