Re: Using a string as filepath
Re: Using a string as filepath
- Subject: Re: Using a string as filepath
- From: Kiel Gillard <email@hidden>
- Date: Thu, 27 Nov 2008 11:22:41 +1100
On 27/11/2008, at 11:09 AM, Knut Lorenzen wrote:
Dear list,
I would like to name a file according to an user defined entry.
However, the user's name entry might be illegal as a filepath,
containing illegal characters for a pathname like "." or "-" as 1st
character, "/", ":", etc.
I've looked into the Cocoa docs for NSString and NSFileManager to no
avail.
Is there a recommended way to "clean" an NSString in order to get a
valid filepath? One could simply replace all suspicious characters
with an underscore (or something else), but that is not very elegant
and feels like fighting the framework.
Can you use NSSavePanel? It handles all that detail for you.
Alternatively, try using NSString's stringByAppendingPathComponent:
method, it may validate the path component you're trying to add.
Kiel
_______________________________________________
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