Type Method 型メソッド

fileURLWithPath:

Initializes and returns a newly created NSURL object as a file URL with a specified path. 新しく作成されたNSURLオブジェクトをファイルURLとして初期化して返します、ある指定されたパスを持ちます。

Declaration 宣言

+ (NSURL *)fileURLWithPath:(NSString *)path;

Parameters パラメータ

path

The path that the NSURL object will represent. path should be a valid system path, and must not be an empty path. If path begins with a tilde, it must first be expanded with stringByExpandingTildeInPath. If path is a relative path, it is treated as being relative to the current working directory. NSURLオブジェクトが表すパス。pathは、有効なシステムパスであるべきです、そして空のパスであってはいけません。pathがチルダで始まるならば、それは最初にstringByExpandingTildeInPathで展開されなければなりません。pathが相対パスならば、それは現在の作業ディレクトリに相対的であるとして扱われます。

Return Value 戻り値

An NSURL object initialized with path. pathで初期化されたNSURLオブジェクト。

Discussion 議論

This method assumes that path is a directory if it ends with a slash. If path does not end with a slash, the method examines the file system to determine if path is a file or a directory. If path exists in the file system and is a directory, the method appends a trailing slash. If path does not exist in the file system, the method assumes that it represents a file and does not append a trailing slash. このメソッドは、pathがディレクトリであると仮定します、もしれそれがスラッシュで終わるならば。pathがスラッシュで終わらないならば、このメソッドはファイルシステムを検査して、pathがファイルまたはディレクトリかを決定します。pathがファイルシステムの中に存在してそしてディレクトリであるならば、メソッドはひとつの後に引きずるスラッシュを追加します。pathがファイルシステムに存在しないならば、メソッドはそれがファイルを表すと仮定します、そして後に引きずるスラッシュを追加しません。

As an alternative, consider using fileURLWithPath:isDirectory:, which allows you to explicitly specify whether the returned NSURL object represents a file or directory. 代わりに、fileURLWithPath:isDirectory:を使うことを考慮してください、それはあなたに明示的にその返されるNSURLオブジェクトがファイルまたはディレクトリを表すかを指定させます。

See Also 参照

Creating an NSURL Object NSURLオブジェクトを作成する