im learning Objective-C with XCode.
Im tying to get the User fu开发者_StackOverflowll path directory, im getting "good" return, but without the user full path (/User/Asinox), just im getting NSPathStore2.
I was trying with NSHomeDirectoryForUser() and with StringByExpandingTildeInPath and the result was the same (NSPathStore2).
Im using XCode 3.2.3 and SDK 4.0.1 on MAC OS X 10.6.4
#import <Foundation/Foundation.h>
void PrintPathInfo(){
//NSString *path = @"~";
NSString *directory = NSHomeDirectoryForUser(@"asinox");//[path stringByExpandingTildeInPath];
NSArray *pathComponents = [directory pathComponents];
NSLog(@"My home folder is at %@", *directory);
NSLog(@"===============================");
for(NSString *ruta in pathComponents){
NSLog(@"%@", ruta);
}
NSLog(@"===============================");
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
PrintPathInfo();
[pool release];
return 0;
}
NSLog(@"My home folder is at %@", *directory);
Should be
NSLog(@"My home folder is at %@", directory);
NSString
is a class cluster.
Because of the nature of class clusters, string objects aren’t actual instances of the NSString or NSMutableString classes but of one of their private subclasses
An NSPathStore2
is a private NSString
subclass that is probably dedicated to dealing with paths, presumably so that path-related methods such as stringByAppendingPathComponent:
or pathExtension
can be performed with greater speed than if it were a non-optimised alternative.
What is the output that you are getting?
精彩评论