iOS Find Files

Source: Internet
Author: User

// Create your own file Manager

Nsfilemanager *manager;

Manager = [nsfilemanager Defaultmanager];

// Get directory path

nsstring *home;

home = [@ "~" stringbyexpandingtildeinpath];

NSLog (@ "%@", Home);

// pass a path string to the file Manager

nsdirectoryenumerator *direnum;

Direnum = [Manager Enumeratoratpath: Home];

// Create an array to put the found path in, because we do not know how many files will be found here, using the

nsmutablearray *files;

Files = [nsmutablearray arraywithcapacity:];

nsstring *filename;

// Loop directory Enumerator returns a nsstring string

while (FileName = [Direnum nextobject])

{

// Determine if the file you want to output is specified

if ([[[FileName pathextension] isequaltostring:@ "jpg"]) /c6>

{

[Files addobject: FileName];

}

}

nsenumerator *fileenum;

Fileenum = [Files objectenumerator];

/// Loop file Enumerator prints out the found file name

while (FileName = [Fileenum nextobject])

{

NSLog (@ "%@", FileName);

}


Quick Enumeration

for (NSString * filename in [manager Enumeratoratpath:home])

//    {

if ([[[FileName pathextension] isequaltostring:@ "jpg"]) {

[Files Addobject:filename];

//        }

//    }

For (NSString *filename in Files)

//    {

NSLog (@ "%@", filename);

//    }


iOS Find Files

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.