• 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: "stephen joseph butler" <email@hidden>
  • Date: Thu, 22 Feb 2007 16:05:14 -0600

2007/2/22, Paul Borokhov <email@hidden>:
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:
        @try {
                ...stuff...
        } @catch (NSException *exception) {
                if ([[[NSUserDefaultsController sharedUserDefaultsController] defaults] boolForKey:@"logErrors"]) {
                        NSLog( @"Notifications Fetch Error");
                        NSLog([[exception name] stringByAppendingString:[exception reason]]);
                }
If "logErrors" is set to TRUE, then I can generate at least one specific error that will crash the app. If it's set to FALSE, the app doesn't crash.
Is this possible, or just a red herring?

You shouldn't ever pass an arbitrary string like this to a formatting function. What if it contains a % escape sequence? Try this:

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

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: Error using categories: 'cannot find interface section for MyClass'
  • Next by Date: Re: Crashing on writing to NSLog?
  • Previous by thread: Crashing on writing to NSLog?
  • Next by thread: Re: Crashing on writing to NSLog?
  • Index(es):
    • Date
    • Thread