Update: So far this works, but I need to put everything else back in. The 
problem with this is that the only way I can think of doing this is following 
this 
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
 to do every single possible value and putting them into the array. There is no 
such thing as id for int, float, ect so I would most likely end up doing that, 
but I'll like there to be an easy way to do it, like inside of the default. Is 
this possible, if so how?

Current code.
va_list ap, *ap2;
size_t size = 0;
ap2 = malloc(size);
int count = 0;
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 '@': {
                        id object = [self quoteObject:va_arg(ap, id)];
                        size += sizeof(object);
                        ap2 = realloc(ap2, size);
                        ap2[count] = (void *)object;
                        break;
                }
                case 's': {
                        const char *string = [self quoteChar:va_arg(ap, const 
char *)];
                        size += sizeof(string);
                        ap2 = realloc(ap2, size);
                        ap2[count] = (void *)string;
                        break;
                }
                default:
                        // Leave this alone.
                        break;
        }
        count++;
        currentFormat = [currentFormat 
substringWithRange:NSMakeRange(range.location+2, [currentFormat 
length]-(range.location+2))];
        range = [currentFormat rangeOfString:@"%"];
}
NSString *result = [[[NSString alloc] initWithFormat:format 
arguments:(va_list)ap2] autorelease];
va_end(ap);
free(ap2);_______________________________________________

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

Reply via email to