Objective-C メソッドを使用NSString
して/Users/user/Projects/thefile.ext
抽出したい場合。thefile
それを実行する最も簡単な方法は何ですか?
ベストアンサー1
NSString リファレンスから取得すると、以下を使用できます。
NSString *theFileName = [[string lastPathComponent] stringByDeletingPathExtension];
呼び出しlastPathComponent
は を返しthefile.ext
、 はstringByDeletingPathExtension
末尾から拡張子サフィックスを削除します。