AGOPair 1.2.0

AGOPair 1.2.0

TestsTested
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.

Requirements

Minimum iOS Target

iOS 8

Usage

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"]);

Installation

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

pod "AGOPair"

Example

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

Author

Alexey Golikov

@AlexeyGolikov

[email protected]

License

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