Re: Extracting file name & path from NSOpenPanel
Re: Extracting file name & path from NSOpenPanel
- Subject: Re: Extracting file name & path from NSOpenPanel
- From: Ondra Cada <email@hidden>
- Date: Mon, 3 Apr 2006 01:25:30 +0200
Phil,
On 3.4.2006, at 0:12, Phil Faber wrote:
That's worked fine. Thanks a lot. I had discovered
'stringWithContentsOfFile' and was working on the assumption that I
needed to find something equivalent such as:
NSString *content = [NSString stringWithFileName:[panel filename]];
You've got a good hunch -- in a sense, you do :)
Not for you debugging purposes, for such cases, plain
NSLog(@"about to open file: \"%@\"",[panel filename]);
or perhaps
NSRunAlertPanel(@"About to open a filename:",@"%@",nil,nil,nil,[panel
filename]);
is completely sufficient and all right, but whilst the [panel
filename] is a perfectly valid NSString containing the path useable
in almost all situations -- it is not quite all right for the one you
want to display the file name to the user. If so happens, what you
need is
NSString *fileNameToBeShown=[[NSFileManager defaultManager]
displayNameAtPath:[panel filename]];
The trick is the filesystem may change the real filename (returned by
the NS*Panel -filename method) to somewhat mangled one for display
purposes, like hiding suffixes, translating some folder names into
the current language, and so forth...
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden