Foundation type feature request: NSPair

Number:rdar://32832794 Date Originated:June 17 2017, 4:51 PM
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification:Suggestion Reproducible:
On many projects I'm working on, I sometimes need to return a pair of objects from a function/method.
Returning a `NSArray` or `NSDictionary` is always possible, of course, but it's not really suitable.

It would be great if the `Foundation` framework had support for a `NSPair` class, acting like `std::pair` in C++.  
It's of course easy to implement, but I think `Foundation` would really benefit having such a class.

Something like:

    @interface NSPair< __covariant FirstType, __covariant SecondType >: NSObject < NSCoding, NSCopying >
    @property( atomic, readwrite, strong, nullable ) FirstType first;
    @property( atomic, readwrite, strong, nullable ) SecondType second;
    - ( instancetype )initWithFirstValue: ( nullable FirstType )first secondValue: ( nullable SecondType )second NS_DESIGNATED_INITIALIZER;

Attached is a proposed implementation.


Proposed implementation:

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!