I'm trying to make sure that this part of my code is good and clean and not leaking. I believe that I have it right (but still think I have something wrong). This code makes a list of file paths, and then copies the files or folders from their location to the destination the user selected. If the item already exists in the destination, I delete it first (to overwrite with new data, yes this is what I intend and the user is aware of how the app works). I've read all your previous responses (Thanks) and it seems like since I am just using "normal" strings that they will be autoreleased on their own. There are now no compiler cautions and the app seems to work OK. A side issue is that I want to add a 2 second delay before closing the sheet that is displayed, is NSTimer the correct item to use? Chris
#import "MyExporter.h" @implementation MyExporter - (IBAction)exportPrefs:(id)sender { NSOpenPanel *theOpenPanel = [NSOpenPanel openPanel]; [theOpenPanel setTitle:@"Choose a folder to save your prefs into:"]; [theOpenPanel setCanChooseDirectories:YES]; [theOpenPanel setCanChooseFiles:NO]; if ([theOpenPanel runModal] == NSOKButton) //if user chooses a folder { NSString *theDestination = [theOpenPanel filename]; //get name NSFileManager *theManager = [NSFileManager defaultManager]; //make an NSFM //if files dont exist on user machine it just seems to bypass copying them NSString *string1 = @"Library/Preferences/Adobe Photoshop CS3 Settings"; NSString *string1a = @"Adobe Photoshop CS3 Settings"; NSString *string2 = @"Library/Preferences/Adobe Illustrator CS3 Settings"; NSString *string2a = @"Adobe Illustrator CS3 Settings"; NSString *string3 = @"Library/Preferences/Adobe InDesign/Version 5.0"; NSString *string3a = @"Version 5.0"; NSString *string4 = @"Library/Preferences/CDFinder Preferences"; NSString *string4a = @"CDFinder Preferences"; NSString *string5 = @"Library/Application Support/Firefox"; NSString *string5a = @"Firefox"; NSString *string6 = @"Library/Safari"; NSString *string6a = @"Safari"; NSString *string7 = @"Library/Application Support/Adobe/Adobe PDF/Settings"; NSString *string7a = @"Settings"; NSString *string8 = @"Library/Preferences/Acrobat Distiller Prefs"; NSString *string8a = @"Acrobat Distiller Prefs"; NSString *string9 = @"Documents/Microsoft User Data"; NSString *string9a = @"Microsoft User Data"; //make 2 arrays with locations of orig prefs, and then short version to save in folder NSArray *myPrefs; myPrefs = [NSArray arrayWithObjects: string1, string2, string3, string4, string5, string6, string7, string8, string9, nil]; NSArray *myPrefsSaved; myPrefsSaved = [NSArray arrayWithObjects: string1a, string2a, string3a, string4a, string5a, string6a, string7a, string8a, string9a, nil]; //start panel here [NSApp beginSheet:exportSheet modalForWindow:mainWindow modalDelegate:self didEndSelector:NULL contextInfo:nil]; [exportProgressBar setDoubleValue:(double)3.0]; //fake ourselves some progress [exportProgressBar displayIfNeeded]; int i; for (i = 0; i < 8; i++) //skip string9 for testing, takes too long to copy { NSString *theSettings = [NSHomeDirectory() stringByAppendingPathComponent:[myPrefs objectAtIndex:i]]; //change/set out variable to this data //loop with each item saving into our destination folder NSString *theDestinationFile = [theDestination stringByAppendingPathComponent:[myPrefsSaved objectAtIndex:i]]; [exportCurrentFileName setStringValue:(@"%@",[myPrefsSaved objectAtIndex:i])]; [exportCurrentFileName displayIfNeeded]; //give a kick to our text box dammit! //delete the old pref file [theManager removeFileAtPath:theDestinationFile handler:nil]; //copy the file [theManager copyPath:theSettings toPath:theDestinationFile handler:nil]; [exportProgressBar incrementBy:(double)11.0]; //11 is arbitrary progress (100 divided by 9 items) [exportProgressBar displayIfNeeded]; } [exportProgressBar setDoubleValue:100.0]; [exportProgressBar displayIfNeeded]; //end sheet here [exportSheet orderOut:nil]; [NSApp endSheet:exportSheet]; } } @end _______________________________________________ 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]