Wired Foundation  2.0
A foundation framework for the Wired implementation on Mac OS X
WITextFilter.m
00001 /* $Id$ */
00002 
00003 /*
00004  *  Copyright (c) 2003-2009 Axel Andersson
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *  1. Redistributions of source code must retain the above copyright
00011  *     notice, this list of conditions and the following disclaimer.
00012  *  2. Redistributions in binary form must reproduce the above copyright
00013  *     notice, this list of conditions and the following disclaimer in the
00014  *     documentation and/or other materials provided with the distribution.
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00017  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
00020  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00023  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00024  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00025  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00026  * POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 #import <WiredFoundation/WITextFilter.h>
00030 
00031 @implementation WITextFilter
00032 
00033 - (id)initWithSelectors:(SEL)selector, ... {
00034         NSMutableArray  *array;
00035         SEL                             eachSelector;
00036         NSUInteger              i;
00037         va_list                 ap;
00038         
00039         self = [super init];
00040         
00041         va_start(ap, selector);
00042 
00043         array = [[NSMutableArray alloc] initWithObjects:NSStringFromSelector(selector), NULL];
00044         
00045         while((eachSelector = va_arg(ap, SEL)))
00046                 [array addObject:NSStringFromSelector(eachSelector)];
00047         
00048         va_end(ap);
00049         
00050         _count = [array count];
00051         _selectors = malloc(_count * sizeof(SEL));
00052         
00053         for(i = 0; i < _count; i++)
00054                 _selectors[i] = NSSelectorFromString([array objectAtIndex:i]);
00055 
00056         [array release];
00057         
00058         return self;
00059 }
00060 
00061 
00062 
00063 - (void)dealloc {
00064         free(_selectors);
00065         
00066         [super dealloc];
00067 }
00068 
00069 
00070 
00071 #pragma mark -
00072 
00073 - (void)filter:(id)string {
00074         NSUInteger              i;
00075         
00076         for(i = 0; i < _count; i++)
00077                 [string performSelector:_selectors[i] withObject:self];
00078 }
00079 
00080 @end
 All Classes