A pretty simple/dumb Objective-C pair object.
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
@interface Pair : NSObject { | |
@public | |
id obj1; | |
id obj2; | |
} | |
- (id)initWithObjects:(id)object, ...; | |
@end | |
@implementation Pair | |
- (id)initWithObjects:(id)object, ... { | |
if ((self = [super init])) { | |
va_list args; | |
va_start(args, object); | |
obj1 = [object retain]; | |
obj2 = [va_arg(args, id) retain]; | |
va_end(args); | |
} | |
return self; | |
} | |
- (void)dealloc { | |
[obj1 release]; | |
[obj2 release]; | |
[super dealloc]; | |
} | |
@end | |
/* A simple Obj-C pair! | |
Initialization: Pair *x = [[Pair alloc] initWithObjects:obj1, obj2]; | |
Member Getting: x->obj1; x->obj2; | |
Member setting: x->obj1 = [obj1 retain]; x->obj2 = [obj2 retain]; | |
Releasing: [x release]; */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment