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

initWithContentsOfFile:encoding:error:

Returns an NSString object initialized by reading data from the file at a given path using a given encoding. NSStringオブジェクトを返します、データをある与えられたパスでのファイルからある与えられた符号化を使って読み出すことによって初期化されます。

Declaration 宣言

- (instancetype)initWithContentsOfFile:(NSString *)path 
                              encoding:(NSStringEncoding)enc 
                                 error:(NSError * _Nullable *)error;

Parameters パラメータ

path

A path to a file. ファイルへのパス。

enc

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

error

If an error occurs, upon return 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 the file named by path using the encoding, enc. The returned object may be different from the original receiver. If the file can’t be opened or there is an encoding error, returns nil. あるNSStringオブジェクト、初期化をpathによって指名されるファイルから符号化encを使ってデータを読み出すことによって行います。返されるオブジェクトは、元のレシーバと異なるかもしれません。ファイルが開かれることができないまたは符号化エラーがあるならば、nilを返します。

Discussion 議論

See Also 参照

Creating and Initializing a String from a File 文字列をファイルから作成して初期化する