From: Sherm Pendley <email@hidden>
To: Jos Timanta Tarigan <email@hidden>
Cc: email@hidden
Sent: Sunday, September 27, 2009 6:29:01 PM
Subject: Re: warning at nslog
On Sun, Sep 27, 2009 at 12:12 PM, Jos Timanta Tarigan
<
email@hidden> wrote:
> i got problem trying to print stuff by using nslog eg. i want to print
> absolute path by this:
>
> NSString *absolutePath = [path stringByExpandingTildeInPath];
>
> and i print it with this
>
> NSLog(absolutePath);
>
> it gives me warning:
>
> Format not a string literal and no format arguments.
>
> i got this error a lot eg trying to print class name, proccesId, etc.
>
> What is this error and how can i handle this?
Omitting the format string is an anti-pattern that's been common for a
long time in C, with many functions such as printf() that also take a
format string argument. Think about what happens at run time if your
path string happens to contain a
format specifier such as %s.
One should always - yes, ALWAYS - use a format string, even when it
adds nothing to the output:
NSLog(@"%@", absolutePath);
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net