Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Forked from qwzybug/WRSides.h
Created May 24, 2011
Embed
What would you like to do?
// I am forking this separately.
#import <Foundation/Foundation.h>
typedef enum _WRSideIdentifier {
kWRSideLeft = 1 << 0,
kWRSideRight = 1 << 1,
kWRSideBottom = 1 << 2,
kWRSideTop = 1 << 3
} WRSideIdentifier
@interface WRSides : NSObject
+ (id)sidesNamed:(WRSideIdentifier)identifiers;
- (void)objectForSide:(WRSideIdentifier)identifier;
@end
#import "WRSides.h"
@interface WRSides()
@property (nonatomic, retain) NSMutableDictionary *sideDictionary;
@end
@implementation WRSides
- (id)init;
{
if (!(self = [super init]))
return nil;
sideDictionary = [[NSMutableDictionary dictionary] retain];
return self;
}
+ (id)sidesNamed:(WRSideIdentifier)identifiers;
{
WRSides *sides = [[[self alloc] init] autorelease];
if (identifiers & kWRSideLeft) [sides.sideDictionary setObject:[MyLeftSide object] forKey:[NSNumber numberWithInt:kWRSideLeft];
//... etc ...
return sides;
}
- (void)objectForSide:(WRSideIdentifier)identifier;
{
return [self.sideDictionary objectForKey:[NSNumber numberWithInt:identifier]];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment