Instance Method インスタンスメソッド

displayNameAtPath:

Returns the display name of the file or directory at a specified path. 指定されたパスでのファイルまたはディレクトリの表示名を返します。

Declaration 宣言

- (NSString *)displayNameAtPath:(NSString *)path;

Parameters パラメータ

path

The path of a file or directory. ファイルまたはディレクトリのパス。

Return Value 戻り値

The name of the file or directory at path in a localized form appropriate for presentation to the user. If there is no file or directory at path, or if an error occurs, returns path as is. pathでのファイルまたはディレクトリの名前、ユーザに提示するのに適切なローカライズされた形式で。pathでファイルまたはディレクトリがないならば、またはエラーが発生するならば、pathがそのまま返されます。

Discussion 議論

Display names are user-friendly names for files. They are typically used to localize standard file and directory names according to the user’s language settings. They may also reflect other modifications, such as the removal of filename extensions. Such modifications are used only when displaying the file or directory to the user and do not reflect the actual path to the item in the file system. For example, if the current user’s preferred language is French, the following code fragment logs the name Bibliothèque and not the name Library, which is the actual name of the directory. 表示名は、ファイルに対するユーザに使いやすい名前です。それらは、概して標準的なファイルおよびディレクトリ名をユーザの言語設定にかなうようローカライズするために使われます。それらはまた他の修正も反映するかもしれません、例えばファイル名拡張子の除去など。そのような修正は、ファイルやディレクトリをユーザに表示する場合にのみ使われます、そしてファイルシステムの中の項目への実際のパスを反映しません。例えば、現在のユーザの優先言語がFrenchならば、以下のコード断片は名前Bibliothèqueを記録して、名前Libraryをそうしません、それはディレクトリの実際の名前です。


NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0)
{
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSFileManager *fileManager = [[NSFileManager alloc] init];
    NSString *displayNameAtPath = [fileManager displayNameAtPath:documentsDirectory];
    NSLog(@"%@", displayNameAtPath);
}

See Also 参照

Getting and Setting Attributes 属性の取得と設定