Working with Paths: NSPathUtilities.h

NSPathUtilities.h includes functions and category extensions to NSString to enable you to manipulate pathnames. You should use these whenever possible to make your program more independent of the structure of the file system and locations of particular files and directories. Program 16.5 shows how to use several of the functions and methods provided by NSPathUtilities.h.

Program 16.5

// Some basic path operations#import <Foundation/Foundation.h>int main (int argc, char * argv[]){   @autoreleasepool {      NSString           *fName = @"path.m";      NSFileManager      *fm;      NSString           *path, *tempdir, *extension, *homedir, *fullpath;      NSArray            *components; ...

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.