Re: Cocoa sometimes raises "minor" exceptions without logging them
Re: Cocoa sometimes raises "minor" exceptions without logging them
- Subject: Re: Cocoa sometimes raises "minor" exceptions without logging them
- From: Matt Neuburg <email@hidden>
- Date: Wed, 17 Mar 2010 10:55:09 -0700
- Thread-topic: Cocoa sometimes raises "minor" exceptions without logging them
On Wed, 17 Mar 2010 09:55:01 -0700, Jerry Krinock <email@hidden> said:
>... And I supposed it could be argued that nothing was wrong, since
constKeyShowStatusMenu is a Boolean property, nil = NO
There is no such thing as a "Boolean property" in the user defaults. The
only things that can go into the user defaults are plist-able values, and a
Boolean is not one of those. When you want to store YES and NO in the user
defaults, you store an NSNumber which is *wrapping* the Boolean value.
NSUserDefaults includes convenience methods for converting a Boolean to an
NSNumber for you (setBool:forKey:, boolForKey:) but the value in the
defaults is itself an NSNumber.
So you are trying to bind a menu item to something in the NSUserDefaults
that isn't there, and you're getting back nil. But nil is not an NSNumber,
or any other kind of plist-able. So the exception is correct.
My guess is that Cocoa is covering up the problem. It throws an exception
(as you discovered by breaking on raise), but in this case I'm betting that
it then proceeds to *handle* that exception (thinking to itself, well, this
is nil, so I'll tell the menu item that the value is NO). You are breaking
before the exception is handled so you're seeing the sausage being made.
That's just a guess, but it explains why nothing gets logged - the exception
never trickles up to the top level, for logging, because it's handled
immediately after the point at which you are breaking.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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