Re: Crashing on writing to NSLog?
Re: Crashing on writing to NSLog?
- Subject: Re: Crashing on writing to NSLog?
- From: Sherm Pendley <email@hidden>
- Date: Thu, 22 Feb 2007 18:55:03 -0500
On Feb 22, 2007, at 5:05 PM, Shawn Erickson wrote:
On 2/22/07, Paul Borokhov <email@hidden> wrote:
Is it possible that I am crashing my application by writing data
to the Console using NSLog? Namely, I have a try/catch block and
in the catch block I write the error's description, like so:
...snip...
NSLog([[exception name] stringByAppendingString:[exception reason]]);
Doing stuff like the above is your problem. NSLog is processing the
first parameter looking for format directives ("%s", "%ld", etc.) and
likely the string you are supply has such directives and that result
in the string formatter attempting to access vargs that don't exist.
Instead you should do the following...
NSLog(@"%@", [[exception name] stringByAppendingString:[exception
reason]]);
Or, since NSLog() will be scanning the format anyway, just skip the
string construction and do:
NSLog(@"%@: %@", [exception name], [exception reason]);
sherm--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________
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