• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Extracting file name & path from NSOpenPanel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Re: Extracting file name & path from NSOpenPanel (From: "Bobby B" <email@hidden>)
 >Re: Extracting file name & path from NSOpenPanel (From: Phil Faber <email@hidden>)

  • Prev by Date: Re: Apple-style expanding preferences panel
  • Next by Date: Re: String memory leak
  • Previous by thread: Re: Extracting file name & path from NSOpenPanel
  • Next by thread: Tiger Intel AS Studio, eSellerate Integrated to Embedded transition
  • Index(es):
    • Date
    • Thread