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

initFileURLWithPath:

Initializes a newly created NSURL referencing the local file or directory at path. 新しく作成されたNSURLを初期化します、pathでのローカルのファイルまたはディレクトリを参照しています。

Declaration 宣言

- (instancetype)initFileURLWithPath:(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 議論

Invoking this method is equivalent to invoking initWithScheme:host:path: with scheme NSURLFileScheme, a nil host, and path. このメソッドを発動することは、initWithScheme:host:path:をスキームNSURLFileSchemenilホスト、そしてpathで発動することに等しいです。

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

See Also 参照

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