mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Override -hash and -isEqual: so that notifications with the name name, object, and userInfo are considered equal. This is the OSX behavior.
This commit is contained in:
parent
ccfb05525e
commit
a9767cdff7
2 changed files with 27 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2020-04-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSNotification.m:
|
||||||
|
Override -hash and -isEqual: so that notifications with the name name,
|
||||||
|
object, and userInfo are considered equal. This is the OSX behavior.
|
||||||
|
|
||||||
2020-04-14 Richard Frith-Macdonald <rfm@gnu.org>
|
2020-04-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/GNUstepBase/GSConfig.h.in:
|
* Headers/GNUstepBase/GSConfig.h.in:
|
||||||
|
|
|
@ -110,6 +110,11 @@ static Class concreteClass = 0;
|
||||||
[self name], [self object], [self userInfo]];
|
[self name], [self object], [self userInfo]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSUInteger) hash
|
||||||
|
{
|
||||||
|
return [[self name] hash] ^ [[self object] hash];
|
||||||
|
}
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
if ([self class] == abstractClass)
|
if ([self class] == abstractClass)
|
||||||
|
@ -122,6 +127,22 @@ static Class concreteClass = 0;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isEqual: (id)other
|
||||||
|
{
|
||||||
|
NSNotification *o;
|
||||||
|
NSObject *v1;
|
||||||
|
NSObject *v2;
|
||||||
|
|
||||||
|
if (NO == [(o = other) isKindOfClass: [NSNotification class]]
|
||||||
|
|| ((v1 = [self name]) != (v2 = [o name]) && ![v1 isEqual: v2])
|
||||||
|
|| ((v1 = [self object]) != (v2 = [o object]) && ![v1 isEqual: v2])
|
||||||
|
|| ((v1 = [self userInfo]) != (v2 = [o userInfo]) && ![v1 isEqual: v2]))
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the notification name.
|
* Returns the notification name.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue