Re: Get path to user preference folder
Re: Get path to user preference folder
- Subject: Re: Get path to user preference folder
- From: Andreas Mayer <email@hidden>
- Date: Sat, 15 Feb 2003 18:19:47 +0100
Am Samstag, 15.02.03 um 16:21 Uhr schrieb Daniel Aarno:
How can I retrieve the path to the a users preference folder in the
correct manner, i.e how can I get ~/Library/Preferences without
hard-coding it in my sources?
This should do it:
@implementation NSFileManager (AMAdditions)
- (NSString *)findSystemFolderType:(int)folderType forDomain:(int)domain
{
FSRef folder;
OSErr err = noErr;
CFURLRef url;
NSString *result = nil;
err = FSFindFolder(domain, folderType, false, &folder);
if (err == noErr) {
url = CFURLCreateFromFSRef(kCFAllocatorDefault, &folder);
result = [(NSURL *)url path];
}
return result;
}
@end
NSString *preferencesFolder = [[NSFileManager defaultManager]
findSystemFolderType:kPreferencesFolderType forDomain:kUserDomain];
You can find the corresponding constants in Folders.h.
Though I did not try it with the preferences folder myself ...
bye. Andreas.
_______________________________________________
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.