Skip to content

Instantly share code, notes, and snippets.

Created November 10, 2013 17:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A pretty simple/dumb Objective-C pair object.
@interface Pair : NSObject {
id obj1;
id obj2;
- (id)initWithObjects:(id)object, ...;
@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];
return self;
- (void)dealloc {
[obj1 release];
[obj2 release];
[super dealloc];
/* 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