Amazon.com Widgets Program 16.4
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 01, 2014, 11:30:57 PM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Program Examples
| | |-+ Chapter 16
| | | |-+ Program 16.4
Pages: [1] Go Down
Print
Author Topic: Program 16.4 (Read 1372 times)
TotalLuck
Full Member
***
Posts: 107



WWW Email




on: February 21, 2009, 04:03:43 PM

Code: (Objective-C)

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   //   **************  16.4
NSString *path;
NSFileManager *fm;
NSDirectoryEnumerator *dirEnum;
NSArray *dirArray;

// Need to create an instance of the file manager

fm = [NSFileManager defaultManager];

// get  current working directory

path = [ fm currentDirectoryPath];

// enumerate the the directory

dirEnum = [ fm enumeratorAtPath: path];

NSLog(@"Contents of %@:", path);

while ((path  = [ dirEnum  nextObject]) != nil )
NSLog(@"%@", path);


// another way to enumerate a directory

dirArray =  [ fm contentsOfDirectoryAtPath:  [fm currentDirectoryPath] error: NULL ];  
NSLog(@"Contents  using contentsOfDirectoryAtPath:error:");  

for ( path in dirArray)
NSLog(@"%@", path);

[pool drain];
    return 0;
}
[/pre]
Last Edit: July 28, 2011, 10:36:22 PM by skochan Logged

Apps available on  iTunes store:
"ADACode"  iPhone and iPad versions, "ADAGuidelines" iPhone & iPad versions,  "Rehabilitation Act of 1973" for iPhone
"APokerTimer" now for iPhone http://bit.ly/h1fAJp
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.