Created
May 15, 2013 09:40
-
-
Save advantis/5582796 to your computer and use it in GitHub Desktop.
Useless HOM sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright © 2012 Yuri Kotov | |
// | |
#import <Foundation/Foundation.h> | |
@interface ADVSafeProxy : NSProxy | |
- (id) initWithObject:(id)object; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright © 2012 Yuri Kotov | |
// | |
#import "ADVSafeProxy.h" | |
@implementation ADVSafeProxy | |
{ | |
id _object; | |
} | |
- (id) initWithObject:(id)object | |
{ | |
_object = object; | |
return self; | |
} | |
- (id) forwardingTargetForSelector:(SEL)selector | |
{ | |
return [_object respondsToSelector:selector] ? _object : nil; | |
} | |
- (NSMethodSignature *) methodSignatureForSelector:(SEL)aSelector | |
{ | |
return [NSMethodSignature signatureWithObjCTypes:"v@:"]; | |
} | |
- (void) forwardInvocation:(NSInvocation *)invocation | |
{ | |
// Do nothing | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright © 2012 Yuri Kotov | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSObject (ADVMessaging) | |
- (id) ifResponds; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright © 2012 Yuri Kotov | |
// | |
#import "NSObject+ADVMessaging.h" | |
#import "ADVSafeProxy.h" | |
@implementation NSObject (ADVMessaging) | |
- (id) ifResponds | |
{ | |
return [[ADVSafeProxy alloc] initWithObject:self]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment