Skip to content

Instantly share code, notes, and snippets.

@cspickert
Last active August 29, 2015 14:22
Show Gist options
  • Save cspickert/5532ac44bc608422628a to your computer and use it in GitHub Desktop.
Save cspickert/5532ac44bc608422628a to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface Box<__covariant T: __kindof NSObject *> : NSObject
@property (nonatomic, readonly) __nonnull T value;
- (nonnull instancetype)initWithValue:(nonnull T)value;
@end
@interface Box<T: __kindof NSObject *> ()
@property (nonatomic) T value;
@end
@implementation Box
@synthesize value = _value;
- (instancetype)initWithValue:(__kindof NSObject *)value
{
if ((self = [super init])) {
self.value = value;
}
return self;
}
- (NSString *)description
{
return [NSString stringWithFormat:@"Box{%@}", self.value.description];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment