Skip to content

Instantly share code, notes, and snippets.

@eiffelqiu
Created May 24, 2011 10:07
Show Gist options
  • Save eiffelqiu/988462 to your computer and use it in GitHub Desktop.
Save eiffelqiu/988462 to your computer and use it in GitHub Desktop.
Common Macro for iphone/ipad project
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#define HEXCOLOR(c) [UIColor colorWithRed:((c>>24)&0xFF)/255.0 \
green:((c>>16)&0xFF)/255.0 \
blue:((c>>8)&0xFF)/255.0 \
alpha:((c)&0xFF)/255.0];
#endif
static inline BOOL isEmpty(id thing) {
return thing == nil
|| (thing == [NSNull null])
|| ([thing respondsToSelector:@selector(length)]
&& [(NSData *)thing length] == 0)
|| ([thing respondsToSelector:@selector(count)]
&& [(NSArray *)thing count] == 0);
}
#define ALog(format, ...) NSLog((@"%s [L%d] " format), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#ifdef DEBUG
#define RSLog(format, ...) ALog(format, ##__VA_ARGS__);
#else
#define RSLog(...)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment