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

subpathsAtPath:

Returns an array of strings identifying the paths for all items in the specified directory. 指定されたディレクトリの中の全ての項目に対するパスを識別する文字列の配列を返します。

Declaration 宣言

- (NSArray<NSString *> *)subpathsAtPath:(NSString *)path;

Parameters パラメータ

path

The path of the directory to list. 一覧にするディレクトリのパス。

Return Value 戻り値

An array of NSString objects, each of which contains the path of an item in the directory specified by path. If path is a symbolic link, this method traverses the link. This method returns nil if it cannot retrieve the device of the linked-to file. NSStringオブジェクトからなる配列、そのそれぞれはpathによって指定されるディレクトリの中のある項目のパスを含んでいます。pathがシンボリックリンクならば、このメソッドはそのリンクを辿ります。このメソッドは、それがリンクされたファイルのデバイスを取ってくることができないならば、nilを返します。

Discussion 議論

This method recurses the specified directory and its subdirectories. The method skips the “.” and “..” directories at each level of the recursion. このメソッドは、指定されたディレクトリとそれの下位ディレクトリを再帰します。このメソッドは、“.” と “..” ディレクトリを再帰の各水準でスキップします。

This method reveals every element of the subtree at path, including the contents of file packages (such as apps, nib files, and RTFD files). This code fragment gets the contents of /System/Library/Fonts after verifying that the directory exists: このメソッドは、pathでの下位ツリーのすべての要素を明らかにします、ファイルパッケージの内容を含めて(例えばアプリ、nibファイル、そしてRTFDファイルなど)。このコード断片は、/System/Library/Fontsの内容を、そのディレクトリが存在することを検証した後に取得します:


BOOL isDir = NO;
NSArray *subpaths;
NSString *fontPath = @"/System/Library/Fonts";
NSFileManager *fileManager = [[NSFileManager alloc] init];
if ([fileManager fileExistsAtPath:fontPath isDirectory:&isDir] && isDir)
    subpaths = [fileManager subpathsAtPath:fontPath];

Special Considerations 特別な注意事項

In macOS 10.5 and later, use subpathsOfDirectoryAtPath:error: instead. macOS 10.5以降では、subpathsOfDirectoryAtPath:error:を代わりに使ってください。

See Also 参照

Discovering Directory Contents ディレクトリ内容を発見する