Thanks to all that helped, here's the code working:

        NSUserDefaults *theDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *dockDict = [theDefaults persistentDomainForName:@"com.apple.dock"]; NSMutableDictionary *mutableDockDict=[dockDict mutableCopyWithZone:nil];
        
        NSArray *apps = [mutableDockDict valueForKey:@"persistent-apps"];
        NSMutableArray *newApps=[NSMutableArray arrayWithCapacity:20];
        BOOL somethingToRemove=NO;
        
        for(NSDictionary *anApp in apps)
        {
NSString *path=[[[anApp valueForKey:@"tile-data"] valueForKey:@"file- data"] valueForKey:@"_CFURLString"]; NSRange range= [path rangeOfString:@"/ pathOfApplicationsIWantToRemove"];
                
                if (range.location != NSNotFound && range.location == 0)
                {
NSLog(@"Removing App From Dock at Path:%@",[[[anApp valueForKey:@"tile-data"] valueForKey:@"file-data"] valueForKey:@"_CFURLString"]);
                        somethingToRemove=YES;
                }
                else
                {
                        [newApps addObject:anApp];
                }
        }
        if (somethingToRemove)
        {
                [mutableDockDict setObject:newApps forKey:@"persistent-apps"];
[theDefaults setPersistentDomain:mutableDockDict forName:@"com.apple.dock"];
                
                //
                // Kill Dock
                //
NSString *quitSource = @"tell application \"/System/Library/ CoreServices/Dock.app\" to quit"; NSAppleScript *quitScript = [[[NSAppleScript alloc] initWithSource:quitSource] autorelease];
                NSDictionary *theError = [[[NSDictionary alloc] init] 
autorelease];

                [quitScript executeAndReturnError:&theError];       
        }
        [NSApp terminate:nil];

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to