'm trying to do a fairly simple copy file process, so I select a file,
and it gets copied to a new location. I seem to be mixing up NSString
and NSURL as I keep getting an NSURL error, can anyone point me down
the right path?
This is what I've got at the moment:
- (IBAction)selectImageFile:(id)sender;
{
NSString* defaultImageLocation;
defaultImageLocation = [NSURL fileURLWithPath: [[self
applicationSupportFolder] stringByAppendingPathComponent: @"/images/"]];
// Create the File Open Dialog class.
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:YES];
// process the files.
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{
NSArray* files = [openDlg filenames];
// process file
NSObject *Product;
Product = [[Products selectedObjects] objectAtIndex:0];
NSString* filePath = [files objectAtIndex:0];
NSString* fileName= [filePath lastPathComponent];
NSMutableString* imagePath;
imagePath = defaultImageLocation;
[imagePath stringByAppendingPathComponent:fileName];
[[ NSFileManager defaultManager ] copyItemAtPath:filePath
toPath:imagePath error:nil];
[Product setValue:imagePath forKey:@"productImage"];
}
}
Many Thanks
Amy
_______________________________________________
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 arch...@mail-archive.com