groups

name language licence
kqueues C Other
Method Replacement (swizzle) Objective-C Other
Safe respondsToSelector: override Objective-C Other
Convert NSScreen visibleFrame to screen coordinates Objective-C Other
Printing callstacks Objective-C Other
Draw single-pixel on top of splitview Objective-C Other
raw fsevents C Other
NSCollectionView Finding View Items in mouseDown: Objective-C Other

< 1 2 3 4 >



language: Objective-C
licence: Other

Method Replacement (swizzle)

options: view full snippetsend 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
	
(Continues...)