Instance Property インスタンスプロパティ

stringByAbbreviatingWithTildeInPath

A new string that replaces the current home directory portion of the current path with a tilde (~) character. ある新しい文字列、それは現在のパスの現在のホームディレクトリ部分をチルダ(~)文字と置き換えます。

Declaration 宣言

@property(readonly, copy) NSString *stringByAbbreviatingWithTildeInPath;

Discussion 議論

A new string based on the current string object. If the new string specifies a file in the current home directory, the home directory portion of the path is replaced with a tilde (~) character. If the string does not specify a file in the current home directory, this method returns a new string object whose path is unchanged from the path in the current string. 現在の文字列オブジェクトに基づく新しい文字列。新しい文字列が現在のホームディレクトリの中のファイルを指定するならば、そのパスのホームディレクトリ部分はチルダ(~)文字と置き換えられます。文字列が現在のホームディレクトリのファイルを指定しないならば、このメソッドはある新しい文字列オブジェクトを返します、それの持つパスは現在の文字列におけるパスから変化しません。

Note that this method only works with file paths. It does not work for string representations of URLs. このメソッドはファイルパスで働くだけであることに注意してください。それはURLの文字列表現に対しては働きません。

For sandboxed apps in macOS, the current home directory is not the same as the user’s home directory. For a sandboxed app, the home directory is the app’s home directory. So if you specified a path of /Users/<current_user>/file.txt for a sandboxed app, the returned path would be unchanged from the original. However, if you specified the same path for an app not in a sandbox, this method would replace the /Users/<current_user> portion of the path with a tilde. macOSでのサンドボックスアプリに対して、現在のホームディレトリはユーザのホームディレクトリと同じではありません。サンドボックスアプリに対して、ホームディレクトリはアプリのホームディレクトリです。それであなたが/Users/<current_user>/file.txtのパスをサンドボックスアプリに指定するならば、返されるパスは元のものから変更されません。しかしながら、あなたがサンドボックスでないアプリに同じパスを指定するならば、このメソッドはパスの/Users/<current_user>部分をチルダと置き換えるでしょう。

See Also 参照

Working with Paths パスを扱う