NSStringのメソッドを使用すれば簡単にファイルパスからファイル名や拡張子などを取り出す事ができる。

●コード
NSString *path = [NSString stringWithFormat:@"Developer/Applications/PathCheck.app"];
NSLog(@"Original = %@", path);
NSLog(@"File Name = %@", [path lastPathComponent]);
NSLog(@"Directory Path = %@", [path stringByDeletingLastPathComponent]);
NSString *fileName = [path lastPathComponent];
NSLog(@"File Name W/O Extension = %@", [fileName stringByDeletingPathExtension]);
NSLog(@"Extension of File Name = %@", [fileName pathExtension]);
NSLog(@"Path Extension Change = %@", [[fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"exe"]);
NSLog(@"Path Components = %@", [path pathComponents]);

●実行結果
2010-05-30 17:21:51.772 NSStringFormatTest[13091:207] Original = Developer/Applications/PathCheck.app
2010-05-30 17:21:51.772 NSStringFormatTest[13091:207] File Name = PathCheck.app
2010-05-30 17:21:51.773 NSStringFormatTest[13091:207] Directory Path = Developer/Applications
2010-05-30 17:21:51.773 NSStringFormatTest[13091:207] File Name W/O Extension = PathCheck
2010-05-30 17:21:51.774 NSStringFormatTest[13091:207] Extension of File Name = app
2010-05-30 17:21:51.775 NSStringFormatTest[13091:207] Path Extension Change = PathCheck.exe
2010-05-30 17:21:51.775 NSStringFormatTest[13091:207] Path Components = (
    Developer,
    Applications,
    "PathCheck.app"
)