Nspathutilities, several common operations on file paths

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.