macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

-stringByStandardizingPath:

INDEX>Foundation>NSString>-stringByStandardizingPath:

指定した文字をパスとみなして、パスをスタンダード化します

パンづくりに困ったら読む本

パンづくりに困ったら読む本


解説

指定した文字をパスとみなして、パスをスタンダード化します。
● -stringByExpandingTildeInPathを使ってチルダ付き「~/」をフルパス「User/username/」に変えます。
● 空のコンポーネントがあれば、それを減らします。「//」や「/./」は「/」に
● シンボリックリンク(エイリアス)を本当のファイルに変えます。
● 最初のコンポーネントを削除します。

返り値

( NSString * )

文字列

引数

クラス

NSString

Instance Methods

使用可能

10.0

参照

- stringByExpandingTildeInPath
- stringByResolvingSymlinksInPath

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSString *str = @"~/";
NSFileManager *myFile = [ NSFileManager defaultManager];
[myFile changeCurrentDirectoryPath:[str stringByStandardizingPath]];
NSLog([myFile currentDirectoryPath]);
}

@end