Amazon.com Widgets program 16.5
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 21, 2014, 02:34:13 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.5
Pages: [1] Go Down
Print
Author Topic: program 16.5 (Read 1364 times)
TotalLuck
Full Member
***
Posts: 107



WWW Email




on: February 21, 2009, 04:23:21 PM

Code: (Objective-C)

// basic path utilities

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *fName = @"path.m";
NSFileManager *fm;
NSString *path, *tempdir, *extention, *homedir, *fullpath;
NSArray         *components;
NSString *upath = @"`stevekochan/progs/../ch16/./path.m";

// Need to create an instance of the file manager

fm = [NSFileManager defaultManager];

// get the temporary working directory

tempdir = NSTemporaryDirectory();

NSLog(@"Temproary directory is %@", tempdir);


// Extract the base directory form current directory

path = [ fm currentDirectoryPath];
NSLog(@"Base directory is %@", [path lastPathComponent]);

//create a full path  to the file  fName in curernt directory

fullpath = [ path stringByAppendingPathComponent: fName ];
NSLog(@"FullPath to %@ is %@ ", fName, fullpath);

// get the file name extention

extention = [ fullpath pathExtension];
NSLog(@"extention for %@ is %@", fullpath, extention);

// get users home directory

homedir = NSHomeDirectory ();
NSLog(@"Your Home directory is %@", homedir);

// Divide a path into its components

components = [homedir pathComponents];

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

// 'Standardize' a path

NSLog(@"%@ => %@", upath, [upath stringByStandardizingPath]);

[pool drain];
    return 0;
}
[/pre]
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.