Skip to content

Instantly share code, notes, and snippets.

View hartbit's full-sized avatar
👨‍💻
Swifting, one commit at a time

David Hart hartbit

👨‍💻
Swifting, one commit at a time
  • Atipik Sàrl & Witty Wings SA
  • Geneva, Switzerland
View GitHub Profile
@hartbit
hartbit / gist:983269
Created May 20, 2011 16:26
Postponed Rendering
- (void)display
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, NULL);
dispatch_async(queue, ^{
size_t contextWidth = [self boundsWidth];
size_t contextHeight = [self boundsHeight];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, contextWidth, contextHeight, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(colorSpace);
@hartbit
hartbit / gist:1035541
Created June 20, 2011 12:34
Property refinement
@interface Superclass : NSObject
@property (strong) id test;
@end
@implementation Superclass
@synthesize test;
@end
@interface Subclass : Superclass
@property (strong) UIView* test;
@protocol ChildProtocol;
@protocol ParentProtocol <NSObject>
@property (nonatomic, strong, readonly) id<ChildProtocol> child;
@end
@protocol ChildProtocol <NSObject>
@property (nonatomic, weak, readonly) id<ParentProtocol> parent;
@end
//
// LaSouris2VideoPageViewController.m
// iConte
//
// Created by David Hart on 7/7/11.
// Copyright 2011 hart[dev]. All rights reserved.
//
#import "LaSouris2VideoPageViewController.h"
@hartbit
hartbit / gist:1247147
Created September 28, 2011 06:34
Instruments - Application crash on Profiling launch
Process: Gravibot [58225]
Path: /Users/USER/Library/Application Support/iPhone Simulator/*/Gravibot.app/Gravibot
Identifier: Gravibot
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: launchd [235]
Date/Time: 2011-09-28 08:33:13.707 +0200
OS Version: Mac OS X 10.7.1 (11B26)
Report Version: 9
{"name":"David Hart","age":26,"color":"Black"}
@hartbit
hartbit / gist:1992031
Created March 7, 2012 08:55
Alternative Expecta Naming
expect(object).beTruthy();
expect(object).to.beTruthy(); // to = no-op
expect(object).toNot.beTruthy(); // noNot = Not
expect(object).will.beTruthy(); // will = isGoing
expect(object).willNot.beTruthy(); // willNot = isNotGoing
// OR ALTERNATIVE CEDAR STYLE
expect(object).be_truthy();
expect(object).to.be_truthy();
@hartbit
hartbit / Child.h
Created March 12, 2012 16:09
ARC weak weird behavior
@interface Child : NSObject
@property (nonatomic, weak, readonly) Parent* parent;
- (id)initWithParent:(Parent*)parent;
@end
@try {
// Exceptions here are not catched
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
matchResult = _matchExceptionBlock(nil);
} @catch (NSException* exception) {
matchResult = _matchExceptionBlock(exception);
}
__block Texture* asyncTexture = nil;
[resourceManager textureWithName:VALID completion:^(Texture* texture) {
asyncTexture = texture;
}];
expect(asyncTexture).willNot.beNil();
expect([resourceManager resourceIsLoadedWithName:VALID]).will.beTruthy();