A convenient and easy to remember function for removing the file extension.
/** Returns only the name of a file without its extension.
It's only a shortcut for `[[ NSString lastPathComponent] stringByDeletingPathExtension]`.
@param str Name of the file (or even the full path).
@return Returns the file name without extension.
*/
+ (NSString *)removeExtensionFromFile:(NSString *)str {
return [[str lastPathComponent] stringByDeletingPathExtension];
}
Download the ready-for-use source file (.m) of Remove the extension from a file
No comments:
Post a Comment