Created
November 4, 2010 21:05
-
-
Save jon/663189 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Prefix header for all source files of the 'MobileAugers' target in the 'MobileAugers' project | |
| // | |
| #ifdef __OBJC__ | |
| #import <Foundation/Foundation.h> | |
| #import <UIKit/UIKit.h> | |
| #define nonatomic_retainProperty(prop, value) do { if (prop != value) { [prop release]; prop = [value retain]; } } while(0); | |
| #define nonatomic_copyProperty(prop, value) do { if (prop != value) { [prop release]; prop = [value copy]; } } while(0); | |
| #define A(obj, objs...) [NSArray arrayWithObjects:obj, ## objs , nil] | |
| #define F(a) [a objectAtIndex:0] | |
| #define I(a, i) [a objectAtIndex:i] | |
| #define R(a) [a subarrayWithRange:NSMakeRange(1, [a length] - 1)] | |
| #define D(k, v) [NSDictionary dictionaryWithObject:v forKey:k] | |
| #define V(o, k) [o objectForKey:k] | |
| #define S(v) [v description] | |
| // Number boxing and unboxing macros | |
| #define Bb(i) [NSNumber numberWithBool:i] | |
| #define Bc(i) [NSNumber numberWithChar:i] | |
| #define Bs(i) [NSNumber numberWithShort:i] | |
| #define Bi(i) [NSNumber numberWithInteger:i] | |
| #define Bl(i) [NSNumber numberWithLong:i] | |
| #define Bll(i) [NSNumber numberWithLongLong:i] | |
| #define Bf(i) [NSNumber numberWithFloat:i] | |
| #define Bd(i) [NSNumber numberWithDouble:i] | |
| #define Ub(n) [n boolValue] | |
| #define Uc(n) [n charValue] | |
| #define Us(n) [n shortValue] | |
| #define Ui(n) [n integerValue] | |
| #define Ul(n) [n longValue] | |
| #define Ull(n) [n longLongValue] | |
| #define Uf(n) [n floatValue] | |
| #define Ud(n) [n doubleValue] | |
| #define iPhone() [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone | |
| #define iPad() [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad | |
| #define Scale() ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0) | |
| #ifdef DEBUG | |
| #define DebugLog(fmt, args...) NSLog(fmt, ## args) | |
| #else | |
| #define DebugLog(fmt, args...) | |
| #endif | |
| #define NilIfEmpty(s) (([s length] > 0) ? s : nil) | |
| #define observe(obj, key, keys...) { for (NSString *k in A(key, ## keys)) [obj addObserver:self forKeyPath:k options:NSKeyValueObservingOptionNew context:nil]; } | |
| #define unobserve(obj, key, keys...) { for (NSString *k in A(key, ## keys)) [obj removeObserver:self forKeyPath:k]; } | |
| #define kvo_updater(target) - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { [self performSelector:target withObject:nil]; } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment