gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception in takeValue:forKey:


From: David Ayers
Subject: Re: Exception in takeValue:forKey:
Date: Wed, 28 Nov 2007 22:07:36 +0100
User-agent: Mozilla Thunderbird 1.0.2 (X11/20070113)

David Wetzel schrieb:
> Hi folks,
> 
> why is this raise there? I should only raise if the key is null as far as I 
> can see.
> 
> - (void) takeValue: (id)anObject forKey: (NSString*)aKey
> {
>   SEL         sel = 0;
>   const char  *type = 0;
>   int         off;
>   unsigned    size = [aKey length] * 8;
>   char                key[size+1];
> 
>   GSOnceMLog(@"This method is deprecated, use -setValue:forKey:");
>   if (anObject == nil)
>     {
>       [NSException raise: NSInvalidArgumentException
>                   format: @"Attempt to set nil value for key '%@'", aKey];
>     }
> (.....)

I agree this looks very dubious to me also.  Classic KVC would only
raise an exception if the attribute were a scalar value.  GSObjCSetVal
takes care of calling setNilValueForKey: (unableToSetNilForKey: with
GDL2) when the attempt is made to set NSNull (EONull) or nil to a scalar
value.

I haven't noticed this because GDL2 replaces the implementation of -base.

Cheers,
David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]