• 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
NSString / NSURL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSString / NSURL


  • Subject: NSString / NSURL
  • From: Amy Heavey <email@hidden>
  • Date: Sat, 28 Aug 2010 15:58:27 +0100

'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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSString / NSURL
      • From: Dave DeLong <email@hidden>
    • Re: NSString / NSURL
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: Transparant button click
  • Next by Date: Re: NSString / NSURL
  • Previous by thread: Re: Translation.
  • Next by thread: Re: NSString / NSURL
  • Index(es):
    • Date
    • Thread