AGOPair 1.2.0

AGOPair 1.2.0

LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2017

Maintained by Alexey Golikov.

AGOPair 1.2.0

An Objective-C class that provides a way to store two objects as a single unit.


Minimum iOS Target

iOS 8


Creating a pair

AGOPair *pair = [[AGOPair alloc] initWithFirst:@"Name" second:@"Second"];
NSLog(@"Pair: %@", pair);

Setting and getting new values

pair.first = @10;
pair.second = @20;
NSLog(@"First: %@, second: %@", pair.first, pair.second);

Both first and second may be nil:

NSDate *date = [NSDate date];
AGOPair *pair = [[AGOPair alloc] initWithFirst:[NSDate date] second:nil];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"your format"];
pair.second = [formatter stringFromDate:date];
NSLog(@"Pair: %@", pair);

You may use subscript expressions for setting and getting values of a pair.

Array-Style Subscripting

AGOPair *pair = [[AGOPair alloc] initWithFirst:@1 second:@2];
pair[0] = @10;
pair[1] = @20;
pair[2] = @30; // does nothing
NSLog(@"First: %@, second: %@", pair[0], pair[1]);

Dictionary-Style Subscripting

AGOPair *pair = [[AGOPair alloc] initWithFirst:@1 second:@2];
pair[@"first"] = @10;
pair[@"second"] = @20;
pair[@"anyotherstring"] = @30; // does nothing
NSLog(@"First: %@, second: %@", pair[@"first"], pair[@"second"]);


AGOPair is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "AGOPair"


To run the example project (tests only), clone the repo, and run pod install from the Example directory first.


Alexey Golikov


[email protected]


AGOPair is available under the MIT license. See the LICENSE file for more info.