On 18 Dec 2015, at 21:33, Ken Thomases <k...@codeweavers.com> wrote:
> On Dec 18, 2015, at 12:23 PM, Jens Alfke <j...@mooseyard.com> wrote:
>> 
>>> On Dec 18, 2015, at 1:24 AM, Graham Cox <graham....@bigpond.com> wrote:
>>> 
>>> I want to display a path to the user. I have a URL, I need to show the 
>>> local file path that represents (it’s always a local file path), where the 
>>> /Users/<username>/ is replaced by ~/
>> 
>> The best methods for this are in NSFileManager:
> 
>> - (NSString *)displayNameAtPath:(NSString *)path;
> 
>> - (nullable NSArray<NSString *> *)componentsToDisplayForPath:(NSString 
>> *)path;
>> 
>> There are other transformations to the path for display besides “~”. For 
>> example, the user should never see “/Volumes”, or hidden suffixes like 
>> “.app”. And some names get completely localized for display — the 
>> “Downloads” directory looks like “Dvökhn¶r” in Elbonian, for example.
> 
> And in a UI, it may be better to use an NSPathControl than to display a path 
> as text.

Definitely recommend using an NSPathControl and to avoid displaying a path at 
all. Most users don't understand file paths. Also keep in mind that display 
names are HFS-style names that may contain slashes, so using a slash as a path 
separator with those can lead to wrong display.

Check out what the "Open recent" submenu does with file names for a good idea 
to follow if you can't use a path control. Particularly how it distinguishes 
between two files with the same name in different locations.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://stacksmith.org





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to