When I have NSString with /Users/user/Projects/thefile.ext I want to extract thefile with Objective-C methods.
NSString
/Users/user/Projects/thefile.ext
thefile
What is the easiest way to do that?
Taken from the NSString reference, you can use :
NSString *theFileName = [[string lastPathComponent] stringByDeletingPathExtension];
The lastPathComponent call will return thefile.ext, and the stringByDeletingPathExtension will remove the extension suffix from the end.
lastPathComponent
thefile.ext
stringByDeletingPathExtension
1.4m articles
1.4m replys
5 comments
57.0k users