How to create a method in Objective-C that takes a NSString stringWithFormat as a parameter?

objective-c

Solution

In the interface,

-(void) showLog: (NSString*) formatSpecifier, ...;

In the implementation

-(void) showLog: (NSString*) formatSpecifier, ...
{
    va_list formatArgs;
    va_start(formatArgs, formatSpecifier);
    NSString* logMessage = [[NSString alloc] initWithFormat: formatSpecifier arguments: formatArgs];
    va_end(formatArgs);

    // Do want you need to to output the string.

    [logMessage release];
}

Problem

I am not sure if the headline is understandable. What I want is to make a convinient method that works like the NSLog method and combines the lines below? This is what I have at the moment : ``` NSString *out = [NSString stringWithFormat:@"something %d,%d",1,2]; [self showLog:out]; ``` How would a method like this look like in the definition ? ``` - (void) showLog:(NSString *) data; ``` Thanks

Original source