• 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
Re: Another AppleScript-ObjC Dictionary question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another AppleScript-ObjC Dictionary question


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

I meant to post to the AS list but I suppose it applies to both, I found it shortly after I posted - allKeys() = note the brackets!

Thanks
Dave


> On 15 Mar 2016, at 15:47, Dave <email@hidden> wrote:
>
> 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


References: 
 >Another AppleScript-ObjC Dictionary question (From: Dave <email@hidden>)

  • Prev by Date: Another AppleScript-ObjC Dictionary question
  • Next by Date: Re: Making Managed Object Context available to array controller in Storyboard scene
  • Previous by thread: Another AppleScript-ObjC Dictionary question
  • Next by thread: Re: PSA: Does your app use Sparkle? Update it, or use an HTTPS server
  • Index(es):
    • Date
    • Thread