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

initWithContentsOfURL:encoding:error:

Returns an NSString object initialized by reading data from a given URL interpreted using a given encoding. NSStringオブジェクトを返します、データをある与えられたURLから読み出すことによって初期化します、与えられた符号化を使って解釈します。

Declaration 宣言

- (instancetype)initWithContentsOfURL:(NSURL *)url 
                             encoding:(NSStringEncoding)enc 
                                error:(NSError * _Nullable *)error;

Parameters パラメータ

url

The URL to read. このURLを読み出します。

enc

The encoding of the file at path. For possible values, see NSStringEncoding. pathでのファイルのその符号化。可能な値として、NSStringEncodingを見てください。

error

If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, pass in NULL. エラーが発生するならば、戻りでは問題を記述するNSErrorオブジェクトを含みます。あなたが起こりうるエラーに興味がないならば、NULLを渡してください。

Return Value 戻り値

An NSString object initialized by reading data from url. The returned object may be different from the original receiver. If the URL can’t be opened or there is an encoding error, returns nil. あるNSStringオブジェクトで、urlからデータを読み出すことによって初期化されます。返されるオブジェクトは、元のレシーバと異なるかもしれません。URLが開かれることができないまたは符号化エラーがあるならば、nilを返します。

Discussion 議論

See Also 参照

Creating and Initializing a String from an URL 文字列をURLから作成して初期化する