Latest 1.2.0
Homepage https://github.com/alexgolikov/AGOPair
License MIT
Platforms ios 8.0
Authors

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

CI Status
Version
License
Platform

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.

Latest podspec

{
    "name": "AGOPair",
    "version": "1.2.0",
    "summary": "An Objective-C class that provides a way to store two objects as a single unit.",
    "description": "This class couples together a pair of values, which may be of different types. The individual values can be accessed through its public members first and second.",
    "homepage": "https://github.com/alexgolikov/AGOPair",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "alexgolikov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/alexgolikov/AGOPair.git",
        "tag": "1.2.0"
    },
    "social_media_url": "https://twitter.com/AlexeyGolikov",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "AGOPair/Classes/*.{h,m}"
}

Pin It on Pinterest

Share This