Skip to content

Instantly share code, notes, and snippets.

View zpasternack's full-sized avatar

Zacharias Pasternack zpasternack

View GitHub Profile
// Makes the text in an NSTextFieldCell vertically centered. Works with single line, non-editable cells.
// Maybe doesn't work with others.
// Stolen from this stackoverflow question:
// http://stackoverflow.com/questions/1235219/is-there-a-right-way-to-have-nstextfieldcell-draw-vertically-centered-text
import Cocoa
class VerticallyCenteredTextFieldCell: NSTextFieldCell {
override func titleRect(forBounds rect: NSRect) -> NSRect {
@zpasternack
zpasternack / NSTableView+Reordering.m
Last active October 21, 2018 01:09
Category on NSTableView for animating rows, using old and new sorted arrays as input. Updated to support items having been removed or added.
@implementation NSTableView (Reordering)
- (void) moveRowsWithOldObjects:(NSArray*)oldObjects newObjects:(NSArray*)newObjects
{
NSMutableArray* oldSortedArray = [oldObjects mutableCopy];
NSArray* newSortedArray = newObjects;
[self beginUpdates];
@zpasternack
zpasternack / ZPAlertView-Example.m
Created October 20, 2010 02:56
Example code for using ZPAlertView
//  MyViewController.m
 
#import “ZPAlertView.h”
#import “MyViewController.h”
 
@implementation MyViewController
 
- (void) doLengthyOperationPrompt {
 enum {
  ButtonIndexCancel = 0,