Skip to content

Instantly share code, notes, and snippets.

View sadatrahman's full-sized avatar

Sadat Rahman sadatrahman

  • Melbourne, Australia
View GitHub Profile
@sadatrahman
sadatrahman / gist:1234895
Created September 22, 2011 14:26 — forked from orj/gist:1234366
A macro to declare a variable number of Objective-C properties in one statement.
#define CAT(a, b) _PRIMITIVE_CAT(a, b)
#define _PRIMITIVE_CAT(a, b) a##b
#define N_ARGS(...) N_ARGS_1(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#define N_ARGS_1(...) N_ARGS_2(__VA_ARGS__)
#define N_ARGS_2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, n, ...) n
#define PROPERTY(policy, ...) CAT(_PROPERTY_, N_ARGS(__VA_ARGS__))(policy, __VA_ARGS__)
#define PROPERTY_STRONG(...) PROPERTY(retain, __VA_ARGS__)
#define PROPERTY_WEAK(...) PROPERTY(assign, __VA_ARGS__)
@sadatrahman
sadatrahman / SRUtilities.m
Created July 12, 2011 09:26
CoreData SQL Debugger
+ (void)installSQLiteDebugger
{
#ifdef DEBUG
[NSClassFromString(@"NSSQLCore") performSelector:@selector(setDebugDefault:) withObject:[NSNumber numberWithBool:YES]];
#endif
}
@sadatrahman
sadatrahman / UIColor+Hex.h
Created June 15, 2011 07:37
UIColor factory category method - returns an appropriate UIColor instance given a hex colour code.
//
// UIColor+Hex.h
// SRKit
//
// Created by Sadat Rahman on 29/11/08.
// Copyright Sadat Rahman 2008. All rights reserved.
//
@interface UIColor (Hex)
//
// TTTableViewDelegateCategory.m
// DELETEME
//
// Created by Mike on 5/6/10.
// Copyright 2010 Prime31 Studios. All rights reserved.
//
#import "TTTableViewDelegateCategory.h"
#ifdef DEBUG
#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
#define DLog(...) do { } while (0)
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
#endif
#define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#endif