• 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: Setting a .plist value?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting a .plist value?


  • Subject: Re: Setting a .plist value?
  • From: Shane Stanley <email@hidden>
  • Date: Sun, 07 Feb 2016 14:05:48 +1100

On 7 Feb 2016, at 10:18 AM, Brian Christmas <email@hidden> wrote:

Code is (for posterity)…

Let's see if we can clean it up a bit first...

on installDockIcon()
-- get the info we need
set defaultsObject to current application's NSUserDefaults's alloc()'s init()
set theInfoRecord to (defaultsObject's persistentDomainForName:"com.apple.dock")
set persistentAppsArray to theInfoRecord's objectForKey:"persistent-apps"
set tileDataArray to persistentAppsArray's valueForKey:"tile-data"
set theLabels to tileDataArray's valueForKey:"file-label"
-- check for match
set hasMatch to (theLabels's containsObject:"Mail Manager") as boolean
set existsMMDockIcon to my installDockItemsTest()
if not hasMatch or not existsMMDockIcon then
-- make new tile-data record
set item_path to (path to applications folder as text) & "Mail Manager:Mail Manager.app"
set item_path to POSIX path of item_path
set newValue to {|file-data|:{_CFURLString:item_path, _CFURLStringType:0}}
-- add it to the old tile-data array
set tileDataArray to tileDataArray's arrayByAddingObject:newValue
-- add new tile-data array to the persistent-apps array
set persistentAppsArray to persistentAppsArray's arrayByAddingObject:tileDataArray
-- update theInfoRecord with the new persistent-apps array
set theInfoRecordNew to (theInfoRecord's mutableCopy()) -- make mutable copy so you can change it
theInfoRecordNew's setObject:persistentAppsArray forKey:"persistent-apps"
-- store the new value
defaultsObject's setPersistentDomain:theInfoRecordNew forName:"com.apple.dock"
tell application "Dock" to quit
end if
end installDockIcon

on installDockItemsTest()
try
tell application "System Events"
tell process "Dock"
set t to (title of UI elements of list 1)
if theTest contains {"Mail Manager"} then return true
end tell
end tell
end try
return false
end installDockItemsTest

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

  • Follow-Ups:
    • Re: Setting a .plist value?
      • From: Brian Christmas <email@hidden>
References: 
 >Re: Setting a .plist value? (From: Brian Christmas <email@hidden>)
 >Fwd: Setting a .plist value? (From: Brian Christmas <email@hidden>)
 >Re: Setting a .plist value? (From: David Gregg <email@hidden>)
 >Re: Setting a .plist value? (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: Setting a .plist value?
  • Next by Date: An improved script for Dock Icon Creator
  • Previous by thread: Re: Setting a .plist value?
  • Next by thread: Re: Setting a .plist value?
  • Index(es):
    • Date
    • Thread