• 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: Crashing on writing to NSLog?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crashing on writing to NSLog?


  • Subject: Re: Crashing on writing to NSLog?
  • From: Manfred Schwind <email@hidden>
  • Date: Thu, 22 Feb 2007 23:08:56 +0100

Is it possible that I am crashing my application by writing data to the Console using NSLog?
[...]
NSLog([[exception name] stringByAppendingString:[exception reason]]);

Note that NSLog takes a format string as first parameter. So you should never pass strings from other/uncontrolled sources as first parameter to NSLog - they may contain format specifications and that may crash your application as you do not provide the expected parameters for the format.


So you should better do this instead:

NSLog(@"%@", [[exception name] stringByAppendingString:[exception reason]]);

or this:

NSLog(@"%@%@", [exception name], [exception reason]);

Regards,
Mani
--
http://www.mani.de/
iVolume - Loudness adjustment for iTunes.
LittleSecrets - The encrypted notepad.
iSale - you sell@eBay.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Crashing on writing to NSLog? (From: Paul Borokhov <email@hidden>)

  • Prev by Date: Re: Crashing on writing to NSLog?
  • Next by Date: Re: Crashing on writing to NSLog?
  • Previous by thread: Re: Crashing on writing to NSLog?
  • Next by thread: Re: Crashing on writing to NSLog?
  • Index(es):
    • Date
    • Thread