| name | language | licence |
|---|---|---|
| Force Application Crash | Objective-C | Other |
| FourCharCode to NSString | Objective-C | Other |
| ROT13 | Objective-C | Other |
| NSIndexSet to String | Objective-C | Other |
| getBoundingClientRect from WebKit using JavaScriptCore | Objective-C | Other |
| NSImage Create QuickLook icon for URL | Objective-C | Other |
| Method Replacement (swizzle) | Objective-C | Other |
| Safe respondsToSelector: override | Objective-C | Other |
< 1 2 3 >
language: Objective-C
licence: Other
Method Replacement (swizzle)
options: view full snippet • send to code collector
/* http://developer.apple.com/samplecode/MethodReplacement/listing3.html */
#import <AppKit/AppKit.h>
#import <objc/runtime.h>
@interface NSWindow (TestMethodReplacement)
- (void)TestMethodReplacement_sendEvent:(NSEvent *)event;
@end
@implementation NSWindow (TestMethodReplacement)
+ (void)load {
if (self == [NSWindow class]) {
// Swap the implementations of -[NSWindow sendEvent:] and -[NSWindow TestMethodReplacement_sendEvent:].
// When the -sendEvent: message is sent to an NSWindow instance, -TestMethodReplacement_sendEvent: will



library
objective-c (22)