Re: adding an additional plist files as resources? possible?
Re: adding an additional plist files as resources? possible?
- Subject: Re: adding an additional plist files as resources? possible?
- From: Ken Hawkins <email@hidden>
- Date: Mon, 27 Sep 2004 18:21:20 -0700
everytime i send a question i answer it myself. sorry for taking space up here and you folks having to be a rhetorical sounding board.
i just copied the plist into the resources dir at build time and then
infoDictionary = [NSDictionary dictionaryWithContentsOfFile:@"subjects.plist"];
// If we succeeded, look for our property.
if ( infoDictionary != NULL ) {
subjects = [infoDictionary objectForKey:@"BJSubjectTypes"];
NSLog([subjects description]);
}
poof worked like a charm!
ken;
On Sep 27, 2004, at 5:29 PM, Ken Hawkins wrote:
let me explain a bit. i have an xml doc (subjects.plist)....
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BJSubjectTypes</key>
<dict>
<key>Animals</key>
<array>
<string>Aliens</string>
<string>Birds</string>
<string>Cats, Kittens</string>
<string>Cows</string>
<string>Dinosaurs</string>
<string>Dogs</string>
<string>Farm Animals</string>
<string>Fish</string>
<string>Horses</string>
<string>Insects</string>
<string>Rabbits</string>
<string>General</string>
<string>Pets</string>
<string>Puppies</string>
<string>Reptiles</string>
<string>Snakes</string>
<string>Wild Animals</string>
</array>
...
</dict>
</dict>
</plist>
and was wondering how to access it from code similar to:
NSDictionary * infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSDictionary * genres = [[NSDictionary alloc] init];
// If we succeeded, look for our property.
if ( infoDictionary != NULL ) {
NSDictionary * genres = [infoDictionary objectForKey:@"CFGenreTypes"];
//NSLog([genres description]);
}
the above loads an entry that i have in place already for genre types which are formatted similar to the above subjects.plist. is it even possible?
the kicker is that if i have to go and add each subject and array within xcode's expert view of the plist entries this could take a while. is there an easier way to load and access a plist? i can add it as a resource but am not sure how i would load and make use of it. can i do this at all? it seems that you could given that you can type in one at a time and keys in the expert view yet i am a bit stumped.
any help? am i making sense or barking up the wrong tree?
thanks,
ken;
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden