Re: Crashing on writing to NSLog?
Re: Crashing on writing to NSLog?
- Subject: Re: Crashing on writing to NSLog?
- From: "Shawn Erickson" <email@hidden>
- Date: Thu, 22 Feb 2007 14:05:55 -0800
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]]);
Note this is true for any function / method that takes a format
string... the format string must match the vargs passed.
-Shawn
_______________________________________________
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