Skip to content

Instantly share code, notes, and snippets.

@qwzybug
Created May 18, 2011 19:57
Show Gist options
  • Save qwzybug/979404 to your computer and use it in GitHub Desktop.
Save qwzybug/979404 to your computer and use it in GitHub Desktop.
#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