pathComponents
レシーバをパスだと見て、パス区切りで区切られている要素を配列にして返します
解説
レシーバをパスだと見て、パス区切りで区切られている要素を配列にして返します。
pathWithComponentの逆
返り値
( NSArray * )
配列
引数
フレームワーク
Foundation
クラス
NSString
Instance Methods
使用可能
10.0
参照
例文
#pragma mark iOS NSString pathComponents -(void)method015 { NSString *str1 = [[NSString alloc] initWithString:@"/tmp/scratch.tiff"]; NSArray *anArray1 = [str1 pathComponents]; NSLog(@"%s %p , %@",__FUNCTION__,str1,anArray1); //=>-[OOOAppDelegate method015] 0x6880 , ("/",tmp,"scratch.tiff") NSString *str2 = [[NSString alloc] initWithString:@"/tmp/"]; NSArray *anArray2 = [str2 pathComponents]; NSLog(@"%s %p , %@",__FUNCTION__,str2,anArray2); //=>-[OOOAppDelegate method015] 0x68b0 , ("/",tmp,"/") NSString *str3 = [[NSString alloc] initWithString:@"scratch.bundle/"]; NSArray *anArray3 = [str3 pathComponents]; NSLog(@"%s %p , %@",__FUNCTION__,str3,anArray3); //=>-[OOOAppDelegate method015] 0x6960 , ("scratch.bundle","/") NSString *str4 = [[NSString alloc] initWithString:@"scratch..tiff"]; NSArray *anArray4 = [str4 pathComponents]; NSLog(@"%s %p , %@",__FUNCTION__,str4,anArray4); //=>-[OOOAppDelegate method015] 0x6970 , ("scratch..tiff") NSString *str5 = [[NSString alloc] initWithString:@".tiff"]; NSArray *anArray5 = [str5 pathComponents]; NSLog(@"%s %p , %@",__FUNCTION__,str5,anArray5); //=>-[OOOAppDelegate method015] 0x6980 , (".tiff") NSString *str6 = [[NSString alloc] initWithString:@"/"]; NSArray *anArray6 = [str6 pathComponents]; NSLog(@"%s %p , %@",__FUNCTION__,str6,anArray6); //=>-[OOOAppDelegate method015] 0x68d0 , ("/") }