NSString's stringWithFormat
NSString's stringWithFormat
- Subject: NSString's stringWithFormat
- From: Shawn Erickson <email@hidden>
- Date: Sat, 10 Jan 2004 17:04:21 -0800
I want to support localization in my application and would like to
leverage existing string methods that support localization. In
particular I want the ability to use standard string files and their
ability to reorder items as needed using the "$" modifier ("Oh %@! %@
failed!" = "%2$@ blah blah, %1$@ oh!");
To that end I am using string files that contain entries like the
following...
"vImage Test Suite - Convole - test" = "Convole %@ x %@ x 32 image with
kernel of size %@";
"vImage Test Suite - Resize - test" = "Resize %@ x %@ x 32 image to %@
x %@ x 32";
That should result in the following...
"Convole 320 x 240 x 32 image with kernel of size 3"
"Resize 320 x 240 x 32 image to 640 x 480 x 32"
The problem that I face however is that I don't know the number of
arguments that will be used at compile time. At run time I am getting
the string key and an array of the correct number of arguments to be
used with that key.
Looking at the docs I only see methods that take a variable number of
arguments ("(id)stringWithFormat:(NSString *)format, ..."), a va_list
of arguments ("initWithFormat:(NSString *)format
arguments:(va_list)argList") but not one that takes an array of
arguments.
It has been a long day but at the moment I don't see how I can convert
my NSArray of arguments (all NSStrings) to a va_list or a method that I
can use.
Any suggestion? I don't want to duplication functionality if I don't
have to and would also like to avoid having to know the number of args
at compile time.
Idiotically,
-Shawn
_______________________________________________
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.