Re: Saving to the home folder
Re: Saving to the home folder
- Subject: Re: Saving to the home folder
- From: Hasan Diwan <email@hidden>
- Date: Wed, 13 Aug 2003 08:58:47 -0700
April:
Either use...
(a) NSString *thePath = [NSString stringWithFormat:@"%@/testFile.dict",
NSHomeDirectory()];
(b) NSString *thePath = [[NSString stringWithString:@"~/testFile.dict"]
stringByExpandingTildeInPath];
... to obtain the path. I believe the second is preferred, but both
work fine. There are probably other ways to do it.
On Tuesday, Aug 12, 2003, at 23:37 US/Pacific, April Gendill wrote:
I am trying to save a file to the home folder automatically.
Mostly because I'm not having any luck reading and writing to the main
bundle.
anyway.
this is the Method I'm using but it does not write anything . If I
change the path to just the root directory it works, but not if I try
to write to the home folder or anywhere else. the method is in test
mode right now, but later there will be actual data written.
- (void)saveFile:(id)sender
{
NSString *thePath=@"~/testFile.dict";
NSMutableDictionary *theDict =[[NSMutableDictionary
alloc]init];
[theDict setObject:@"Value" forKey:@"Key"];
[theDict writeToFile:thePath
atomically:YES];
}
I use a performSelector call to invoke this, although in the end it
will probably be -(void)saveFile:(NSDictionary *)aDictionary
so I can call it simply with [self saveFile]; Anyway. I must assume
that the way I'm entering the path is incorrect. So how do I get it to
write to the home folder?
Hasan Diwan {
http://ibn.com/~hdiwan}
OpenPGP Fingerprint: 275D 0E84 550C D92A 4A56 732C 8528 2579 E6E9 4842
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.