Re: warning at nslog
Re: warning at nslog
- Subject: Re: warning at nslog
- From: Sherm Pendley <email@hidden>
- Date: Sun, 27 Sep 2009 12:29:01 -0400
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden