Re: File Path String From Save Panel
Re: File Path String From Save Panel
- Subject: Re: File Path String From Save Panel
- From: Lee Ann Rucker <email@hidden>
- Date: Mon, 04 Mar 2013 12:38:30 -0800
On Mar 4, 2013, at 8:25 AM, Peter Hudson wrote:
> I recover the path string from a Save Panel like so :-
>
> NSArray *pathComponents = [[sp URL] pathComponents];
>
> When I put them together again to use to write a file, any spaces in the file name are turned in symbols.
>
> Any suggestions what I am doing wrong ?
My first smart-alec reaction is to say "taking it apart and putting it back together", but seriously, that isn't a good idea. URLs aren't Unix file paths. If you've got a valid NSURL, why not keep it around and use it later? Which raises the question - how are you using it to write a file? If it's NSFileManager methods, the original NSURL is all you need; if lower-level or methods that only have NSString versions, use [NSURL path].
If you do need to split the path up, it would help to know why. lastPathComponent, pathExtension, and URLBy[Appending/Deleting]PathComponent should cover most of what you need to do with file paths. The last time I cared about pathComponents wasn't for file IO, it was for a "Recent Items" -style name disambiguator - you know, how it'll show just the lastPathComponent until there are two that match, and then it finds the first non-matching component.
_______________________________________________
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