Skip to content

Instantly share code, notes, and snippets.

View madebyjeffrey's full-sized avatar

Jeffrey Drake madebyjeffrey

View GitHub Profile
@madebyjeffrey
madebyjeffrey / CABasicAnimation
Created November 16, 2010 20:31
Adapting an example, doesn't work fully yet
- (void) present
{
CABasicAnimation *a;
a = [CABasicAnimation animationWithKeyPath: @"transform.scale"];
a.duration = 6;
a.repeatCount = 0;
a.autoreverses = NO;
a.fromValue = [NSNumber numberWithFloat: 0];
@madebyjeffrey
madebyjeffrey / NSColor+CGColor
Created November 16, 2010 06:30
CGColor property for NSColor
// Version 3: Simplified, but still can have an exception thrown in the case of a non-floating point colour space.
@implementation NSColor (CGColor)
@dynamic CGColor;
- (CGColorRef) CGColor
{
CGColorSpaceRef colorspace = [[self colorSpace] CGColorSpace];
const NSInteger nComponents = [self numberOfComponents];
// The Controller:
// The controller is created:
viewDidLoad:
CGRect starsize = CGRectMake(0, 0, 2048, 2048);
self.starmap.scrollView.bounds = starsize;
self.starmap.frame = starsize;
[self.starmap setNeedsDisplay];
/*
This code present a way to implement textView:doCommandBySelector, as sent by an NSTextView to its delegate, and implement the method as - (BOOL) method: (NSTextView*)aTextView and avoid the need for if statement chaining.
*/
- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector {
if ([self respondsToSelector: aSelector]) {
BOOL (*method)(id, SEL, NSTextView*);
method = (BOOL (*)(id, SEL, NSTextView*))[self methodForSelector: aSelector];
return method(self, aSelector, aTextView);
} else {