Help!!!

whitesaint

cocoa love
The method "stringByExpandingTildeInPath" won't work for me. Can anyone help please?

here is a code snippet:


NSString * myString = @"~/Desktop/";
[myString stringByExpandingTildeInPath];
NSLog(@"myString = %@", myString);


But i keep getting the same "~/Desktop/"! Am I doing somthing wrong? Help!!
 
Originally posted by whitesaint
The method "stringByExpandingTildeInPath" won't work for me. Can anyone help please?

here is a code snippet:


NSString * myString = @"~/Desktop/";
[myString stringByExpandingTildeInPath];
NSLog(@"myString = %@", myString);


But i keep getting the same "~/Desktop/"! Am I doing somthing wrong? Help!!

stringByExpandingTildeInPath returns the result, it doesn't modify the original, so you want:
Code:
NSString *myString = @"~/Desktop/";
NSString *expanded = [ myString stringByExpandingTildeInPath ];
NSLog(@"expanded = %@", expanded);

You can also get the home with:
Code:
char *home = getenv( "HOME" );
 
Back
Top