Skip to content

Instantly share code, notes, and snippets.

View lerno's full-sized avatar

Christoffer Lerno lerno

View GitHub Profile
class Bar : NSObject
{
var ref : (()->Bool)?
deinit { println("Bye from bar!") }
}
class Foo : NSObject
{
var bar : Bar
override init()
@lerno
lerno / gist:d6305411fe95410d68c5
Last active August 29, 2015 14:05
Object serialization
#import <objc/runtime.h>
@interface TestObject : NSObject
@property (nonatomic, strong) NSString *aString;
@property (nonatomic, assign) int aNumber;
@property (nonatomic, strong) NSArray *anArray;
@property (nonatomic, strong) NSDictionary *aDict;
@property (nonatomic, strong) TestObject *childObject;
@end
@lerno
lerno / gist:bd70286ca7c9bc5e5f7d
Created August 17, 2014 13:43
Trivial method for setting properties
- (void)setProperties:(NSDictionary *)keyToPropertyDictionary fromDictionary:(NSDictionary *)properties
{
for (id key in [keyToPropertyDictionary keyEnumerator])
{
id value = properties[key];
if (!value) continue;
value = [NSNull null] == value ? nil : value;
id realKey = keyToPropertyDictionary[key];
NSError *error = nil;
if (![self validateValue:&value forKey:realKey error:&error])
extension GameCenter
{
struct NotificationKey
{
static let Error = "error"
static let Achievement = "achievement"
}
struct Notification
{