Why isn't this working???? (NSURL and files)
Why isn't this working???? (NSURL and files)
- Subject: Why isn't this working???? (NSURL and files)
- From: Francisco Tolmasky <email@hidden>
- Date: Tue, 1 Apr 2003 18:35:27 -0800
I'm trying to work with NSURL, but for some reason it's not working.
WHen I convert from a string to an NSURL it isn't doing it or
something. Here is my code:
NSMutableDictionary *_assignmentTypesDictionary;
//...
+ (NSMutableDictionary *)types
{
if(!_assignmentTypesDictionary)
{
NSString *str= [[[NSFileManager defaultManager]
findSystemFolderType:kApplicationSupportFolderType
forDomain:kUserDomain] stringByAppendingString:@"types.gds"];
NSURL *typesFile= [NSURL URLWithString: [@"file://"
stringByAppendingString: str]];
if([[NSFileManager defaultManager] fileExistsAtPath: [typesFile
path]])
_assignmentTypesDictionary= [NSMutableDictionary
dictionaryWithContentsOfURL: typesFile];
else
{
_assignmentTypesDictionary= [[NSMutableDictionary alloc]
initWithObjectsAndKeys:
[NSColor redColor], @"Homework", [NSColor blueColor],
@"Quiz", [NSColor greenColor], @"Test",
[NSColor yellowColor], @"Lab", nil];
[_assignmentTypesDictionary writeToFile: [typesFile path]
atomically: YES];
}
}
return _assignmentTypesDictionary;
}
For some reason, it does not write the file, and if I say
NSLog([typesFile path]) nothing is printed. I've tried without
@"file://" and also with @"file:/". I've also tried using writeToURL
instead of writeToFile:.
Note: [[NSFileManager defaultManager]
findSystemFolderType:kApplicationSupportFolderType
forDomain:kUserDomain];
just returns @"Users/name/Library/Application\ Support/"
Also, is there any way of checking to see if a directory exists? And
how do u make directories?
Thank you in advance,
Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
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.