Re: NSString, stringByAppendingPathComponent, and Canonicalization
Re: NSString, stringByAppendingPathComponent, and Canonicalization
- Subject: Re: NSString, stringByAppendingPathComponent, and Canonicalization
- From: Sean McBride <email@hidden>
- Date: Thu, 07 Apr 2011 17:51:34 -0400
- Organization: Rogue Research Inc.
On Mon, 4 Apr 2011 22:19:07 -0500, Stephen J. Butler said:
>> I need to accept a filename from the user. Given the user supplied
>> filename, I form a fully qualified name:
>>
>> NSString* pathName = [NSHomeDirectory(),
>> stringByAppendingPathComponent:@"Documents"];
>> NSString* fullPathName = [pathName
> stringByAppendingPathComponent:filename];
>
>First, you should be getting the path to the documents folder via
>NSSearchPathForDirectoriesInDomains():
Even better is not not use NSStrings/paths at all and use NSURLs
instead. In that case you'd use URLF
orDirectory:inDomain:appropriateForURL:create:error: instead of
NSSearchPathForDirectoriesInDomains().
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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