• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: warning at nslog
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: warning at nslog
      • From: Jos Timanta Tarigan <email@hidden>
References: 
 >warning at nslog (From: Jos Timanta Tarigan <email@hidden>)

  • Prev by Date: warning at nslog
  • Next by Date: Re: warning at nslog
  • Previous by thread: warning at nslog
  • Next by thread: Re: warning at nslog
  • Index(es):
    • Date
    • Thread