mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +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
|
@ -110,6 +110,11 @@ static Class concreteClass = 0;
|
|||
[self name], [self object], [self userInfo]];
|
||||
}
|
||||
|
||||
- (NSUInteger) hash
|
||||
{
|
||||
return [[self name] hash] ^ [[self object] hash];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ([self class] == abstractClass)
|
||||
|
@ -122,6 +127,22 @@ static Class concreteClass = 0;
|
|||
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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue