Re: NSString / NSURL
Re: NSString / NSURL
- Subject: Re: NSString / NSURL
- From: Dave DeLong <email@hidden>
- Date: Sat, 28 Aug 2010 09:08:18 -0600
Oh duh. imagePath is an NSURL, because defaultImageLocation is an NSURL, and stringByAppendingPathComponent: is an NSString method.
Dave
On Aug 28, 2010, at 9:03 AM, Dave DeLong wrote:
> This is incorrect:
>
>> NSString* fileName= [filePath lastPathComponent];
>> NSMutableString* imagePath;
>> imagePath = defaultImageLocation;
>>
>> [imagePath stringByAppendingPathComponent:fileName];
>>
>> [[ NSFileManager defaultManager ] copyItemAtPath:filePath toPath:imagePath error:nil];
>> [Product setValue:imagePath forKey:@"productImage"];
>
> Just because you declare a pointer to an NSMutableString does not mean you actually have an NSMutableString. In this case, you have an NSString (since defaultImageLocation is a immutable string). Also, you're ignoring the return value of stringByAppendingPathComponent:, so after that method invocation, imagePath is still equivalent to defaultImageLocation.
>
> I'm guessing that it's failing because you're trying to copy a file (at filePath) to the location of a directory (imagePath).
>
> Dave_______________________________________________
>
> 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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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