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 09:56:39 -0700
On Sep 27, 2006, at 5:20 AM, Dev WO wrote:
Hello Jan,
thanks for the pointer.
I did:
NSDictionary dict = (NSDictionary)
NSPropertyListSerialization.propertyListFromString
((rm.inputStreamForResourceNamed("text.strings", FrameworkName,
null)).toString());
but got to the following crash:
-----------
A fatal exception occurred: propertyListFromString parsed an
object, but there's still more text in the string. A plist should
contain only one top-level object.
----------
I checked to see if there's any commentaries in the string file
that could lead to something like that... but nothing.
I might have done something wrong...
Check that the strings file has {...} around it like this:
{
key1="value one";
key2="value two";
}
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
_______________________________________________
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