Skip to content

Instantly share code, notes, and snippets.

@akuraru
Last active December 23, 2015 09:59
Show Gist options
  • Save akuraru/6618829 to your computer and use it in GitHub Desktop.
Save akuraru/6618829 to your computer and use it in GitHub Desktop.
Objective-Cでタプル
#define tuple(_1, _2) [Tuple tupleWithFirst:_1 second:_2];
@interface Tuple : NSObject
@property (readonly, nonatomic) id _1;
@property (readonly, nonatomic) id _2;
+ (id)tupleWithFirst:(id)_1 second:(id)_2;
- (id)initWithFirst:(id)_1 second:(id)_2;
@end
@implementation Tuple
+ (id)tupleWithFirst:(id)_1 second:(id)_2 {
return [[self alloc] initWithFirst:_1 second:_2];
}
- (id)initWithFirst:(id)_1 second:(id)_2 {
self = [super init];
if (self) {
__1 = _1;
__2 = _2;
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment