Hello, I'm wanting to let's say escape strings and objects in a va_list before I use NSString to place the format together into one string. I know that on OS X va_list is just a char * that is an array, so I know I should be able to make one manually in code, but how is the question. I read http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html and that's how I know va_list is a char *. Here is what I have come up with so far, I just need to know how to replace the value of the object with a new one, and the value of the string with the new one, and to just leave everything else the same. I would expect that I'll have to make a a new char * with the arguments and the changes or at least have a reference to the start of the va_list so I can send that back to NSString's initWithFormat:arguments:.
va_list ap; va_start(ap, format); if (format==nil) return; NSString *currentFormat = format; NSRange range = [currentFormat rangeOfString:@"%"]; while (range.location!=NSNotFound) { unichar character = [currentFormat characterAtIndex:range.location+1]; NSLog(@"%C", character); switch (character) { case '@': // Do something with the object. break; case 's': // Do something with the string. break; default: // Leave this alone. break; } currentFormat = [currentFormat substringWithRange:NSMakeRange(range.location+2, [currentFormat length]-(range.location+2))]; range = [currentFormat rangeOfString:@"%"]; } NSString *result = [[[NSString alloc] initWithFormat:format arguments:ap] autorelease]; va_end(ap); I know this is something hard to understand, I hope that code snippet above will help you understand what I'm trying to do. Any help at all will be greatly appreciated. Thanks, Mr. Gecko_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com