Skip to content

Instantly share code, notes, and snippets.

@davbeck
davbeck / NSObject+TUBlockDealloc.h
Created November 29, 2012 01:23
Execute block on dealloc
//
// NSObject+TUBlockDealloc.h
// ThinkGV
//
// Created by David Beck on 4/20/12.
// Copyright (c) 2012 ThinkUltimate LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@davbeck
davbeck / gist:3661211
Created September 6, 2012 23:19
NSTimer with block
_actionDelayTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:[NSBlockOperation blockOperationWithBlock:^{
NSLog(@"Well this is useless.");
}] selector:@selector(start) userInfo:nil repeats:YES];
@davbeck
davbeck / Example
Created May 14, 2012 21:49
CGContextClipToDrawing is a CGContext function for clipping with drawing in a block.
- (void)drawRect:(CGRect)drawRect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextClipToDrawing(context, self.bounds, ^(CGContextRef maskContext, CGRect rect){
UIGraphicsPushContext(maskContext);
[[UIColor whiteColor] setFill];
CGContextFillRect(maskContext, rect);
@davbeck
davbeck / NSImage+TMStretchable.h
Created January 12, 2012 02:14
A category to draw an NSImage using 9 slice stretching
//
// NSImage+TMStretchable.h
// ThinkMessenger
//
// Created by David Beck on 1/11/12.
// Copyright (c) 2012 ThinkUltimate. All rights reserved.
//
#import <AppKit/AppKit.h>