Nspathutilities, about the file path of a few common operations, familiar with, stitching path what, feeling still quite good.
The original path. Simply add an image to the project to test NSString *strpath =[[nsbundle Mainbundle] pathforresource:@ "002" oftype:@ "PNG"]; NSLog (@ "path======%@", strpath);//Gets the last layer of the path nsstring *strallname = [strpath lastpathcomponent]; NSLog (@ "allname===%@", strallname);//Remove the last layer of the path nsstring *strfilepath = [strpath stringbydeletinglastpathcomponent]; NSLog (@ "filepath==%@", strFilePath);//Remove extension nsstring *strname = [Strallname stringbydeletingpathextension]; NSLog (@ "strname===%@", strName);//Get extension nsstring *strextension = [strpath pathextension]; NSLog (@ "extension=%@", strextension);
Run result 2015-05-06 18:20:48.638 test03[3470:1708111] path======/private/var/mobile/containers/bundle/application/ 9a142ec0-a29f-42df-aff6-c36e448271ae/test03.app/002.png2015-05-06 18:20:48.639 test03[3470:1708111] allName=== 002.png2015-05-06 18:20:48.640 test03[3470:1708111] filepath==/private/var/mobile/containers/bundle/application/ 9a142ec0-a29f-42df-aff6-c36e448271ae/test03.app2015-05-06 18:20:48.640 test03[3470:1708111] strName=== 0022015-05-06 18:20:48.641 test03[3470:1708111] Extension=png
Nspathutilities, several common operations on file paths