Re: Need to remove Dock icon
Re: Need to remove Dock icon
- Subject: Re: Need to remove Dock icon
- From: Shane Stanley <email@hidden>
- Date: Wed, 14 Sep 2016 14:40:20 +1000
On 14 Sep 2016, at 1:47 PM, Brian Christmas <email@hidden> wrote:
I have no idea how to use NSUserDefaults, and copied something I found on the net, which has a dearth of information on the term.
You didn't search very hard -- did you search for "AppleScript NSUserDefaults"? Or perhaps search the two ASObjC books on your hard drive? Or even search for past posts to this list?
Here's a post to this list from February this year:
Code is (for posterity)…
on installDockIcon() try
set theInfo to (current application's NSUserDefaults's alloc()'s init()'s persistentDomainForName:"com.apple.dock") as record
So I reckon the person who posted that might know at least something about NSUserDefaults. He goes by the name of Brian Christmas. Heck, I can see a post where the same guy used NSUserDefaults back in 2012. Maybe you should speak to him. OK, I take your point I should not interfere, but if there’s absolutely no way I can remove a dock icon, just say so in plain terms
I don't know whether there is or not -- I haven't tried. I'm just saying don't expect there necessarily is, and stop trying to do it via the property list file, because that's guaranteed to be unreliable at best. If there is a way that works reliably, it will be via defaults and do shell script, or by using NSUserDefaults.
To do it via NSUserDefaults you can use something like this:
use AppleScript version "2.4" -- Yosemite (10.10) or later use framework "Foundation" use framework "AppKit" use scripting additions
set defaults to current application's NSUserDefaults's standardUserDefaults() -- get existing values set theValues to (defaults's persistentDomainForName:"com.apple.dock") as record -- modify theValues to suit in here, then set to the new values... defaults's setPersistentDomain:theValues forName:"com.apple.dock"
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden