ftp.nice.ch/Attic/openStep/developer/resources/MiscKit.2.0.5.s.gnutar.gz#/MiscKit2/Frameworks/MiscFoundation/MiscNotificationCenter.m

This is MiscNotificationCenter.m in view mode; [Download] [Up]

/*	MiscNotificationCenter.m

	Copyright 1995 Christopher J. Kane.

	This notice may not be removed from this source code.
	The use and distribution of this software is governed by the
	terms of the MiscKit license agreement.  Refer to the license
	document included with the MiscKit distribution for the terms.

	Version 1 (1 February 1995)
	    - Hidden object functionality added
*/

#import <MiscNotificationCenter.h>
#import <Foundation/Foundation.h>

@implementation MiscNotificationCenter

- (id)init {
    self = [super init];
    NSAssert(nil != self, @"object super initialization failed");
    _hiddenObjectsWithNil = [NSMutableSet set];
    _hiddenObjectsWithProxies = [NSMutableDictionary dictionary];
    return self;
}

- (void)dealloc {
    [_hiddenObjectsWithNil release];
    [_hiddenObjectsWithProxies release];
    [super dealloc];
}

- (void)postNotification:(NSNotification *)notification {
    id notifyObj = [notification object];
    if ([_hiddenObjectsWithNil containsObject:notifyObj])
	notification = [NSNotification notificationWithName:[notification name] object:nil userInfo:[notification userInfo]];
    else {
	id proxy = [_hiddenObjectsWithProxies objectForKey:notifyObj];
	if (proxy != nil)
	    notification = [NSNotification notificationWithName:[notification name] object:proxy userInfo:[notification userInfo]];
    }
    [super postNotification:notification];
}

/* Support registration of objects which are "masked" from notifications */

- (void)addHiddenObject:(id)anObject withProxy:(id)aProxy {
    NSParameterAssert(anObject != nil);
    [self removeHiddenObject:anObject];
    if (aProxy == nil)
	[_hiddenObjectsWithNil addObject:anObject];
    else
	[_hiddenObjectsWithProxies setObject:aProxy forKey:anObject];
}

- (void)removeHiddenObject:(id)anObject {
    NSParameterAssert(anObject != nil);
    [_hiddenObjectsWithNil removeObject:anObject];
    [_hiddenObjectsWithProxies removeObjectForKey:anObject];
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.