Re: Converting a .strings text file to a NSArray or NSDictionary
Re: Converting a .strings text file to a NSArray or NSDictionary
- Subject: Re: Converting a .strings text file to a NSArray or NSDictionary
- From: Chuck Hill <email@hidden>
- Date: Wed, 27 Sep 2006 12:16:34 -0700
On Sep 27, 2006, at 12:08 PM, Dev WO wrote:
Hi Chuck:)
Check that the strings file has {...} around it like this:
{
key1="value one";
key2="value two";
}
Actually this is correct.
Meaning that is they way they are already? If so,
NSPropertyListSerialization will handle them. If you are getting
exceptions then carefully check the contents of the file, something
is wrong in it.
It seems I have to implement a complete parser for my .strings
files. I'll most probably be using it quite often, so I'm ready to
invest some time to do it.
I'll be using it for 3 type of thing:
-get a complete NSDictionary or NSArray from a .strings
NSPropertyListSerialization already does that.
-get a partial NSDictionary or NSArray from a .strings based on a
qualifer like "key contains xxxxx" (easy if I can get a complete
NSArray)
It won't do that.
-create a reverse NSDictionary/Array from value to key (I know I'll
have to ensure the uniqueness of the value on my own if I do that)
What would be the best way to approach this? and maybe some pointer
for the following steps;)
I'd still use NSPropertyListSerialization and use another class to
get the last two points from above.
Chuck
Hi Xavier,
you could read the content of your InputStream into a String and
then use NSPropertyListSerialization to parse that String into a
dictionary:
NSDictionary dict = (NSDictionary)
NSPropertyListSerialization.propertyListFromString(fileContent);
Jan
Am 26.09.2006 um 12:06 schrieb Dev WO:
Hi:)
I've got a resource in my Framework (text.strings), I know I
can access a specific key using WOResourceManager.stringForKey,
but I need to create an array of all the key in the file.
I first though I could go through an InputStream like
rm.inputStreamForResourceNamed ("text.strings", FrameworkName,
null))
but I'm not sure what to do next...
I think I'm probably not going the easiest way. Maybe
WOResourceManager already has a feature to get all the key-
value in a NSArray or NSDictionary, but I can't find it.
Any pointer is greatly appreciated.
Thanks
Xavier_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve
specific problems. http://www.global-village.net/products/
practical_webobjects
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden