Variable arguments at runtime modification
Variable arguments at runtime modification
- Subject: Variable arguments at runtime modification
- From: Bertrand Mansion <email@hidden>
- Date: Sun, 12 Oct 2003 16:34:24 +0200
Hi,
I would like my method:
- (SCFResult *)queryWithFormat:(NSString *)format arguments:(id)first, ...
to take a variable number of arguments and, for each one, encode it to a
string if it is of type NSData. I already have my encodeBinary method ready
that returns a NSString from a NSData.
The problem is that I would like my queryWithFormat method to return a
NSString using the format it is given and the datas, after they have been
encoded to NStrings.
Here is what I have started to write:
- (SCFResult *)queryWithFormat:(NSString *)format arguments:(id)first, ...
{
va_list values;
id value;
NSString *query;
va_start(values, first);
while ((value = va_arg(values, id)) != nil) {
// Here encode if it is NSData with a method that returns a NSString
}
va_end(values);
query = [NSString stringWithFormat:format, XXX];
return [self queryWithString:query];
}
I know how to encode the data, etc. What I don't know, is how to make a new
va_list with the new encoded datas (shown as XXX in the snippet above) and
pass it to stringWithFormat. Is this even possible or should I go for
another solution ?
I would really appreciate some help, let me know if my explanations weren't
clear enough.
Thanks,
Bertrand Mansion
Mamasam
http://cocoa.mamasam.com
_______________________________________________
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.