Skip to content

Instantly share code, notes, and snippets.

@ruandao
Created October 16, 2014 09:05
Show Gist options
  • Select an option

  • Save ruandao/c3d5dd49fa1976fcfef9 to your computer and use it in GitHub Desktop.

Select an option

Save ruandao/c3d5dd49fa1976fcfef9 to your computer and use it in GitHub Desktop.
Prefix.h
#ifndef yahame_Prefix_h
#define yahame_Prefix_h
#if !defined(DEBUG)
//#define NSLog(...) ;
#endif
#define NS_USERDEFAULT [NSUserDefaults standardUserDefaults]
#define LocStr(key) NSLocalizedString(key,@"")
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define UI_TOP_VIEW [[[[UIApplication sharedApplication] keyWindow] subviews] lastObject]
#define NULL_TO_NIL(obj) ({ __typeof__ (obj) __obj = (obj); __obj == [NSNull null] ? nil : obj; })
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
/// For when you need a weak reference of an object, example: `BBlockWeakObject(obj) wobj = obj;`
#define BlockWeakObject(o) __typeof__(o) __weak
/// For when you need a weak reference to self, example: `BBlockWeakSelf wself = self;`
#define BlockWeakSelf BlockWeakObject(self)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment