MacOS compatibility fix.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22705 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-03-24 13:47:41 +00:00
parent a0c912a825
commit 07ac9849eb
2 changed files with 13 additions and 20 deletions

View file

@ -4,6 +4,7 @@
* Source/unix/GSRunLoopCtxt.m:
* Source/win32/GSRunLoopCtxt.m:
Tidy/improve removal of triggered watchers from outer contexts.
* Source/NSDictionary.m: ([valueForKey:]) conform to MacOS spec
2006-03-21 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
<title>NSDictionary class reference</title>
$Date$ $Revision$
@ -1039,30 +1040,21 @@ compareIt(id o1, id o2, void* context)
/**
* Default implementation for this class is to return the value stored in
* the dictionary under the specified key, or nil if there is no value.
* the dictionary under the specified key, or nil if there is no value.<br />
* However, if the key begins with '@' that character is stripped from
* it and the superclass implementation of the method is used.
*/
- (id) valueForKey: (NSString*)key
{
id o = [self objectForKey: key];
id o;
if (o == nil)
if ([key hasPrefix: @"@"] == YES)
{
if ([key isEqualToString: @"count"] == YES)
{
o = [NSNumber numberWithUnsignedInt: [self count]];
}
else if ([key isEqualToString: @"allKeys"] == YES)
{
o = [self allKeys];
}
else if ([key isEqualToString: @"allValues"] == YES)
{
o = [self allValues];
}
if (o != nil)
{
NSWarnMLog(@"Key '%@' would return nil in MacOS-X Foundation", key);
}
o = [super valueForKey: [key substringFromIndex: 1]];
}
else
{
o = [self objectForKey: key];
}
return o;
}