Hi, in Script: Split RTF(D) at Font Sizes I get DEVONthink’s rich text font and font size via NSUserDefaults. This works if run from Script Debugger but now that I finished the script I found that it doesn’t seem to be possible to get NSUserDefaults if ran from the scripts menu,
This line …
set theDefaults to current application's NSUserDefaults's alloc()'s initWithSuiteName:"com.devon-technologies.think3"
… returns missing value
which leads to error
It doesn’t seem to be a general problem, it’s e.g. possible to get DEVONagent’s NSUserDefaults from DEVONthink’s script menu.
Test - DEVONagent's NSUserDefaults
-- Test - DEVONagent NSUserDefaults from within DEVONthink
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
try
set theDefaults to current application's NSUserDefaults's alloc()'s initWithSuiteName:"com.devon-technologies.agent"
set theTest to ((theDefaults's dictionaryRepresentation())'s stringForKey:"AppleInterfaceStyle")
display dialog (theTest as string)
on error error_message number error_number
activate
if the error_number is not -128 then display alert "Error: \"Test NSUserDefaults\"" message error_message as warning
error number -128
end try
But this fails
-- Test - NSUserDefaults from within DEVONthink
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
try
set theDefaults to current application's NSUserDefaults's alloc()'s initWithSuiteName:"com.devon-technologies.think3"
set theFontName to ((theDefaults's dictionaryRepresentation())'s stringForKey:"RichFontName")
--> Error: missing value versteht die Nachricht „dictionaryRepresentation“ nicht.
display dialog (theFontName as string)
on error error_message number error_number
activate
if the error_number is not -128 then display alert "Error: \"Test NSUserDefaults\"" message error_message as warning
error number -128
end try
Any idea what’s going on?