Need help adding an Icon to the dock using "defaults"

Discussion in 'Mac Programming' started by bensonang, Mar 18, 2010.

  1. bensonang macrumors newbie

    Mar 12, 2010
    The code below works perfectly in adding an icon to the dock.

    NSAppleScript* placeInDock = [[[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"do shell script \"	defaults write persistent-others -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/myFolder/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict><key>tile-type</key><string>directory-tile</string></dict>'\""]] autorelease];
    My problem is that when I add the Dock icon, it is a folder and I want it to show as a FOLDER icon, not the stacks.

    How do I do this? I tried to add
    after <key>tile-data</key> but it does not work. Instead, the code won't work anymore.

    Any help would be appreciated.
  2. larkost macrumors 6502a

    Oct 13, 2007
    The easiest way to do this from the command line would be to use dockutil. For full disclosure I have contributed some code to that project.
  3. kainjow Moderator emeritus


    Jun 15, 2000

Share This Page