Type Method 型メソッド

stringWithContentsOfFile:

Returns a string created by reading data from the file named by a given path. 与えられたパスによって指名されるファイルからデータを読み出すことによって作成される文字列を返します。

Declaration 宣言

+ (id)stringWithContentsOfFile:(NSString *)path;

Discussion 議論

If the contents begin with a Unicode byte-order mark (U+FEFF or U+FFFE), interprets the contents as UTF-16 code units. If the contents begin with a UTF-8 byte-order mark (EFBBBF), interprets the contents as UTF-8. Otherwise, interprets the contents as data in the default C string encoding. Since the default C string encoding will vary with the user’s configuration, do not depend on this method unless you are using Unicode or UTF-8 or you can verify the default C string encoding. Returns nil if the file can’t be opened. 内容がユニードバイトオーダーマーク(U+FEFFまたはU+FFFE)で始まるならば、内容はUTFー16コード単位として解釈します。内容がUTF-8バイトオーダーマーク(EFBBBF)で始まるならば、内容をUTF-8として解釈します。そうでなければ、内容をデータとして省略時のC文字列符号化で解釈します。省略時のC文字列符号化はユーザの構成設定によって変動することから、このメソッドに依存しないでください、あなたがユニコードまたはUTFー8を使っているまたはあなたが省略時のC文字列符号化を検証できるのでない限り。nilを返します、もしファイルが開かれることができないならば。

See Also 参照

Deprecated 非推奨

Related Documentation 関連文書