Skip to content

Instantly share code, notes, and snippets.

View tolmasky's full-sized avatar

Francisco Ryan Tolmasky I tolmasky

View GitHub Profile
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
class_addIvar(AppController, "hello", "CPString");
alert(self.hello === nil);
}
@import <AppKit/CPView.j>
@import "_Ace/ace.js"
@import "_Ace/theme-twilight.js"
@implementation AceView : CPView
{
Editor m_editor;
}
@implementation LongPressAndPanGestureRecognizer
- (id)initWithTarget:(id)aTarget action:(SEL)anAction
{
self = [super initWithTarget:aTarget action:anAction];
if (self)
[self addObserver:self forKeyPath:@"view" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
@interface _KeyPathObserver : NSObject
@end
@implementation NSObject (Additions)
- (void)performSelector:(SEL)aSelector forChangesInKeyPath:(NSString *)aKeyPath
{
[self addObserver:(id)[_KeyPathObserver class] forKeyPath:aKeyPath options:NSKeyValueObservingOptionNew context:aSelector];
}
@interface _KeyPathObserver : NSObject
@end
@implementation NSObject (Additions)
- (void)performSelector:(SEL)aSelector forChangesInKeyPath:(NSString *)aKeyPath
{
[self addObserver:(id)[_KeyPathObserver class] forKeyPath:aKeyPath options:NSKeyValueObservingOptionNew context:aSelector];
}
//
// UIView+PropertyAdditions.m
//
// Created by Francisco Tolmasky on 7/3/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "NSObject+KVOAdditions.h"
#import "UIView+KVOAdditions.h"
UIImageView * imageView = (UIImageView *)aGestureRecognizer.view;
draggedView = [[UIImageView alloc] initWithImage:[imageView image]];
UIWindow * window = [self.view window];
BOOL areEnabled = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
draggedView.frame = [imageView.superview convertRect:imageView.frame toView:window];
[window addSubview:draggedView];
-[UIGestureRecognizer _updateGestureWithEvent:] ()
-[UIApplication _cancelGestureRecognizers:] ()
-[UIView(Hierarchy) _willMoveToWindow:] ()
-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] ()
-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] ()
-[UIView(Hierarchy) removeFromSuperview] ()
-[UITableViewCell removeFromSuperview] ()
-[UITableView(_UITableViewPrivate) _updateAnimationDidStop:finished:context:] ()
-[UIViewAnimationState sendDelegateAnimationDidStop:finished:] ()
+[UIViewAnimationState popAnimationState] ()
@tolmasky
tolmasky / Example1.js
Created November 1, 2011 04:29
On HTML5 Drag and Drop
document.addEventListener("dragstart", function(event)
{
event.dataTransfer.setData("image/png", slides.imageRep());
event.dataTransfer.setData("slides", slides.serializedRep());
// etc.
}, false);
@tolmasky
tolmasky / Example1.js
Created November 1, 2011 05:13
Building a Better JavaScript Profiler with WebKit
document.addEventListener("click", function() { /*...*/ }, false);