stringByExpandingTildeInPath
チルダ付きのパスをフルパスにして返します
解説
チルダ付きのパスをフルパスにして返します。
チルダ付きというのはユーザーディレクトリであるということ
チルダ付きの記法にするには - stringByAbbreviatingWithTildeInPathを使います。
返り値
( NSString * )
フルパス
引数
フレームワーク
Foundation
クラス
NSString
使用可能
10.0
例文
#pragma mark iOS NSString stringByExpandingTildeInPath -(void)method016 { NSString *str1 = [[NSString alloc] initWithString:@"~/tmp/scratch.tiff"]; NSLog(@"%s %p , %@",__FUNCTION__,str1,[str1 stringByExpandingTildeInPath]); //=>-[OOOAppDelegate method016] 0x399d0 , /var/mobile/Applications/00000000-0000-0000-0000-000000000000/tmp/scratch.tiff NSString *str2 = [[NSString alloc] initWithString:@"/tmp/scratch.tiff"]; NSLog(@"%s %p , %@",__FUNCTION__,str2,[str2 stringByExpandingTildeInPath]); //=>-[OOOAppDelegate method016] 0x39890 , /tmp/scratch.tiff }
"~/Desktop/test.png".stringByExpandingTildeInPath