directoryContentsAtPath:
pathで指定したディレクトリのファイル名の一覧を返します
-(NSArray *)directoryContentsAtPath:(NSString *)path:
解説
pathで指定したディレクトリ(フォルダ)のファイル名の一覧を返します。
エラーが起こればnilを返します。
pathで指定したディレクトリ(フォルダ)がなければnilを返します。
pathで指定したディレクトリ(フォルダ)の中身が無ければ、空の配列を返します。
指定したディレクトリ(フォルダ)の中だけを探して、含まれているディレクトリ(フォルダ)の中までは探しません。
シンボリックリンク、エイリアスもそのファイルを返して、元ファイルは返しません。
返り値
( NSArray * )
ファイル名の一覧の配列
引数
( NSString * )path
ディレクトリのパス
フレームワーク
Foundation
クラス
NSFileManager
Instance Methods
使用可能
10.0
参照
- currentDirectoryPath
- fileExistsAtPath:isDirectory:
- enumeratorAtPath:
- subpathsAtPath:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSString *str = @"~/"; NSFileManager *myFile = [ NSFileManager defaultManager]; [myFile changeCurrentDirectoryPath:[str stringByExpandingTildeInPath]]; NSLog([[myFile directoryContentsAtPath:@"Documents"] description]); } @end