Created
July 25, 2010 03:02
-
-
Save Alos/489252 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// iDrawAppDelegate.m | |
// iDraw | |
// | |
// Created by Alos on 7/22/10. | |
// Copyright 2010 __MyCompanyName__. All rights reserved. | |
// | |
#import "iDrawAppDelegate.h" | |
#import "MyViewController.h" | |
#include <objc/runtime.h> | |
@implementation iDrawAppDelegate | |
@synthesize window; | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | |
// Insert code here to initialize your application | |
} | |
void drawWithRedInk(id self, SEL _cmd, NSRect *rect){ | |
NSLog(@"Using red ink"); | |
[[NSColor redColor] set]; | |
[[self valueForKey:@"path"] stroke]; | |
} | |
-(IBAction)loadDynamicCode: (id) sender{ | |
NSLog(@"Adding new code!!!"); | |
Method newMethod = class_getInstanceMethod([iDrawAppDelegate class], @selector(drawWithRedInk)); | |
class_replaceMethod([MyViewController class], @selector(drawRect:), (IMP)drawWithRedInk, method_getTypeEncoding(newMethod)); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment