Raise NSUnknownKeyException

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/freeze-1_6_0@16021 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2003-02-20 04:57:25 +00:00
parent 853114cb50
commit 94e2176828
3 changed files with 30 additions and 8 deletions

View file

@ -1,3 +1,9 @@
2003-02-19 Adam Fedor <fedor@gnu.org>
* Source/NSKeyValueCoding.m ([NSObject -handleQueryWithUnboundKey:]):
Raise NSUnknownKeyException.
([NSObject -handleTakeValue:forUnboundKey:]): Idem.
2003-02-18 Adam Fedor <fedor@gnu.org>
* Source/GSFFIInvocation.m (GSFFIInvocationCallback): Cast

View file

@ -33,6 +33,8 @@
#ifndef STRICT_OPENSTEP
GS_EXPORT NSString* const NSUnknownKeyException;
@interface NSObject (NSKeyValueCoding)
+ (BOOL) accessInstanceVariablesDirectly;

View file

@ -37,6 +37,8 @@
#include <Foundation/NSKeyValueCoding.h>
#include <Foundation/NSNull.h>
/** An exception for an unknown key */
NSString* const NSUnknownKeyException = @"NSUnknownKeyException";
/**
* This describes an informal protocol for key-value coding.
@ -58,19 +60,31 @@
- (id) handleQueryWithUnboundKey: (NSString*)aKey
{
[NSException raise: NSGenericException
format: @"%@ -- %@ 0x%x: Unable to find value for key \"%@\"",
NSStringFromSelector(_cmd), NSStringFromClass([self class]), self, aKey];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
self,
@"NSTargetObjectUserInfoKey",
aKey,
@"NSUnknownUserInfoKey",
nil];
NSException *exp = [NSException exceptionWithName: NSUnknownKeyException
reason: @"Unable to find value for key"
userInfo: dict];
[exp raise];
return nil;
}
- (void) handleTakeValue: (id)anObject forUnboundKey: (NSString*)aKey
{
[NSException raise: NSGenericException
format: @"%@ -- %@ 0x%x: Unable set value \"%@\" for key \"%@\"",
NSStringFromSelector(_cmd), NSStringFromClass([self class]),
self, anObject, aKey];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
anObject,
@"NSTargetObjectUserInfoKey",
aKey,
@"NSUnknownUserInfoKey",
nil];
NSException *exp = [NSException exceptionWithName: NSUnknownKeyException
reason: @"Unable to set value for key"
userInfo: dict];
[exp raise];
}
- (id) storedValueForKey: (NSString*)aKey