// // NSSet+NGAAdditions.m // MarkdownPreview // // Created by Michael Bishop on 11/3/11. // Copyright (c) 2011 Numerical Garden LLC. All rights reserved. // #import "NSSet+NGAAdditions.h" #import "NGAUtilities.h" @implementation NSSet (NGAAdditions) -(id)setByRemovingObjects:(NSSet*)excludedObjects { if ( excludedObjects == nil || [excludedObjects count] == 0 ) return AUTORELEASE( RETAIN(self) ); NSMutableSet * survivingObjects = [NSMutableSet setWithCapacity:[self count]]; for (id item in self) { if ( ![excludedObjects containsObject:item] ) [survivingObjects addObject:item]; } return [NSSet setWithSet:survivingObjects]; } -(id)setByRemovingObject:(id)excludedObject { if ( excludedObject == nil ) return AUTORELEASE( RETAIN(self) ); return [self setByRemovingObjects:[NSSet setWithObject:excludedObject]]; } @end