Rough analogue of C++ static_cast and dynamic_cast
//
// Copyright © 2012 Yuri Kotov
//
#import "NSObject+ADVCasting.h"
@implementation NSObject (ADVCasting)
+ (instancetype) staticCast:(id)from
{
return from;
}
+ (instancetype) dynamicCast:(id)from
{
return [from isKindOfClass:self] ? from : nil;
}
@end
//
// Copyright © 2012 Yuri Kotov
//
#import <Foundation/Foundation.h>
@interface NSObject (ADVCasting)
+ (instancetype) staticCast:(id)from;
+ (instancetype) dynamicCast:(id)from;
@end