Objective-c Foundation Framework example:looking for files find file

Source: Internet
Author: User

Objective-c Foundation Framework example:looking for files find file

Nsfilemanager. The Nsfilemanager class lets you does stuff with the file system, like create directories, remove files, move files around, And get information about files.

Nsfilemanager: Lets you handle some file system things, such as creating directories, removing files, moving files, and getting information about files.

main.m//helloworld////Created by kfx on 15-5-4.//Copyright (c) 2015 COM. Mysupercompany. All rights reserved.//#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) {@autoreleasepo        OL {Nsfilemanager *manager;                  Manager = [Nsfilemanager Defaultmanager];        NSString *home;                  home = [@ "~" Stringbyexpandingtildeinpath];                  Nsdirectoryenumerator *direnum;//Directory Enumeration direnum = [Manager enumeratoratpath:home];        Nsmutablearray *files;                  Files = [Nsmutablearray arraywithcapacity:42];        NSString *filename;                while (filename = [Direnum Nextobject]) {if ([[FileName pathextension] Isequalto: @ "jpg"]) {            [Files Addobject:filename];        }} nsenumerator *fileenum;        Fileenum = [Files Objectenumerator];        while (filename = [Fileenum nextobject]) {NSLog (@ "%@", filename); }} return 0;} 

  

return 0;

}

Where in the file system to start looking at files?

Starting from the top level of your hard drive could take a long time, so let's just look in your home directory.

Start in the home directory.

Luckily, Unix (and OS X) have a shorthand character for the home directory, which is ~ (also known as the tilde).

UNIX and OS X have a simple string representing the home directory.

Objective-c Foundation Framework example:looking for files find file

Related Article

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.