componentsToDisplayForPath:
Returns an array of strings representing the user-visible components of a given path.
Parameters
- path
- A pathname.
Return Value
An array of
NSString
objects representing the user-visible (for the Finder, Open and Save panels, and so on) components of path. Returns nil
if path does not exist.Discussion of [NSFileManager componentsToDisplayForPath]
These components cannot be used for path operations and are only suitable for display to the user.
Example of [NSFileManager componentsToDisplayForPath]
- (NSString *)displayPathForPath:(NSString *)path
{
NSEnumerator *e;
NSArray *components;
NSString *displayPath = @"";
NSString *pathComponent;
components = [self componentsToDisplayForPath:path];
if (!components) //Unable to localize path, return the raw string
{
return path;
}
e = [[self componentsToDisplayForPath:path] objectEnumerator];
while (pathComponent = [e nextObject])
{
displayPath = [displayPath stringByAppendingPathComponent:pathComponent];
}
return displayPath;
}