Created
May 18, 2011 19:57
-
-
Save qwzybug/979404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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