OBJECTIVE-C Self-study Note (3)-use of data sets

Source: Internet
Author: User
Tags inheritance





Hit by the example on the book:



#import <Foundation / Foundation.h>
int main (int argc, const char * argv []) {
    @autoreleasepool {
        // Declaration of file management objects
        NSFileManager * manager;
        // Create NSFileManager initialization by defaultManager method
        manager = [NSFileManager defaultManager];
        // Declaration to traverse the path
        NSString * home;
        // Initialize the directories to be traversed: user root directory
        home = [@ "~" stringByExpandingTildeInPath];
        // Declaration file traversal object
        NSDirectoryEnumerator * direnum;
        // Initialize the file traversal object, and use the file directory object home as a parameter
        direnum = [manager enumeratorAtPath: home];
        // variable list to save traversed files
        NSMutableArray * files;
        // The initial size is set to 42
        files = [NSMutableArray arrayWithCapacity: 42];
        // enumerate the iterated objects
        NSString * filename;
        // Use the iterative method to iterate through all the elements in the enumeration one by one
        while (filename = [direnum nextObject]) {
            // Determine if the file is a jpg file
            if ([[filename pathExtension] isEqualTo: @ "jpg"]) {
                // Add the file name to the list
                [files addObject: filename];
            }
        }
        // Declaration file list enumeration
        NSEnumerator * fileenum;
        // Initialize the enumeration object
        fileenum = [files objectEnumerator];
        // enumerate through all elements
        while (filename = [fileenum nextObject]) {
            // Print information
            NSLog (@ "% @", filename);
        }
    }; // autoreleasepool
    return 0;
} // main



Output



2015-01-27 23: 00: 11.181 04.01 Shapes-Inheritance [449: 9009] Desktop / psb.jpg
2015-01-27 23: 00: 11.194 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / QPR / 15.jpg
2015-01-27 23: 00: 11.194 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / QPR / 19.jpg
2015-01-27 23: 00: 11.194 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / QPR / 22.jpg
2015-01-27 23: 00: 11.195 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / QPR / 24.jpg
2015-01-27 23: 00: 11.195 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / QPR / 4.jpg
2015-01-27 23: 00: 11.195 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / QPR / QPR.numbers / preview-micro.jpg
2015-01-27 23: 00: 11.195 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / QPR / QPR.numbers / preview-web.jpg
2015-01-27 23: 00: 11.196 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / QPR / QPR.numbers / preview.jpg
2015-01-27 23: 00: 11.196 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Burnley / 11.jpg
2015-01-27 23: 00: 11.196 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Burnley / 21.jpg
2015-01-27 23: 00: 11.196 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Burnley / 7.jpg
2015-01-27 23: 00: 11.215 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Burnley / Burnley.numbers / preview-micro.jpg
2015-01-27 23: 00: 11.215 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Burnley / Burnley.numbers / preview-web.jpg
2015-01-27 23: 00: 11.215 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Burnley / Burnley.numbers / preview.jpg
2015-01-27 23: 00: 11.216 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Chelsea / 10.jpg
2015-01-27 23: 00: 11.216 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Chelsea / 14.jpg
2015-01-27 23: 00: 11.216 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Chelsea / 19.jpg
2015-01-27 23: 00: 11.217 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Chelsea / 2.jpg
2015-01-27 23: 00: 11.217 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Chelsea / 21.jpg
2015-01-27 23: 00: 11.217 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Chelsea / 4.jpg
2015-01-27 23: 00: 11.218 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Chelsea / 7.jpg
2015-01-27 23: 00: 11.218 04.01 Shapes-Inheritance [449: 9009] Documents / aodci / Player Information / Chelsea / chelsea.numbers / preview-micro.jpg


 





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.