The following are some of the development will often use the macro, simple to organize, in order to be more convenient to use in the future, so as to improve the efficiency of development, do not take more time for this.
Also hope that everyone can add, thus making it more imposing!
/** is printed when it is developed, but it is not printed when it is released nslog*/
#ifdef DEBUG
#define NSLOG (...) NSLog (@ "%s line%d \%@\n\n", __func__,__line__,[nsstring stringwithformat:__va_args__])
#else
#define NSLOG (...)
#endif
#pragma mark-base
/** Weak References */
#define KWEAKSELF (Type) __weak typeof (Type) weak# #type = type;
/** Strong Quote */
#define KSTRONGSELF (Type) __strong typeof (type) type = weak# #type;
/** convert radians by angle */
#define Kdegreestoradian (x) (M_PI * (x)/180.0)
/** the angle of conversion from radians */
#define Kradiantodegrees (Radian) (Radian *180.0)/(M_PI)
/** get some time interval */
#define Kstarttime Cfabsolutetime start = Cfabsolutetimegetcurrent ();
#define Kendtime NSLog (@ "Time:%f", Cfabsolutetimegetcurrent ()-start)
#pragma mark-size
Get screen width related to height
#define KSCREENWIDTH \
([[UIScreen mainscreen] Respondstoselector: @selector (nativebounds)]? [Uiscreenmainscreen].nativebounds.size.width/[uiscreen mainscreen].nativescale: [UIScreen MainScreen]. Bounds.size.width)
#define KSCREENHEIGHT \
([[UIScreen mainscreen] Respondstoselector: @selector (nativebounds)]? [Uiscreenmainscreen].nativebounds.size.height/[uiscreen mainscreen].nativescale: [UIScreen MainScreen]. Bounds.size.height)
#define KSCREENSIZE \
([[UIScreen mainscreen] Respondstoselector: @selector (nativebounds)]? Cgsizemake ([Uiscreenmainscreen].nativebounds.size.width/[uiscreen Mainscreen].nativescale,[uiscreenmainscreen]. Nativebounds.size.height/[uiscreen mainscreen].nativescale): [UIScreen mainscreen].bounds.size)
Get screen rect related
#define SCREEN_RECT ([UIScreen mainscreen].bounds)
#define SCREEN_WIDTH ([UIScreen mainscreen].bounds.size.width)
#define Screen_height ([UIScreen mainscreen].bounds.size.height)
#define Content_height (Screen_height-navigation_bar_height-status_bar_height)
#pragma mark-color
/** Color */
#define Krgbcolor (R, G, b) [Uicolor colorwithred: (R)/255.0green: (g)/255.0blue: (b)/255.0alpha:1.0]
#define Krgbacolor (R, G, B, a) [Uicolor colorwithred: (R)/255.0green: (R)/255.0blue: (r)/255.0alpha:a]
#define Krandomcolor Krgbcolor (Arc4random_uniform (/255.0,arc4random_uniform)/255.0,arc4random_uniform (2 56)/255.0)
#define KCOLORWITHHEX (Rgbvalue) \
[Uicolor colorwithred: ((float) ((Rgbvalue &0xff0000) >>16))/255.0\
Green: ((float) ((Rgbvalue &0xff00) >>8)/255.0\
Blue: ((float) (Rgbvalue &0xff))/255.0alpha:1.0]
#pragma mark-check
/** whether the string is empty */
#define KSTRINGISEMPTY (str) ([str iskindofclass:[nsnull class]] | | str = = NIL | | [str length] <1? Yes:no)
/** whether the array is empty */
#define KARRAYISEMPTY (array) (array = = Nil | | [Array Iskindofclass:[nsnull class] | | Array.count ==0)
Whether the/** dictionary is empty */
#define KDICTISEMPTY (DIC) (dic = = Nil | | [dic Iskindofclass:[nsnull class] | | Dic.allkeys ==0)
Whether the/** is an empty object */
#define KOBJECTISEMPTY (_object) (_object = = nil \
|| [_object Iskindofclass:[nsnull class]] \
|| ([_object respondstoselector: @selector (length)] && [(NSData *) _object length] ==0) \
|| ([_object respondstoselector: @selector (count)] && [(Nsarray *) _object Count] ==0))
/** Judging whether it is iphone*/
#define Kisiphone (ui_user_interface_idiom () = = Uiuserinterfaceidiomphone)
/** Judging whether it is ipad*/
#define KISIPAD (ui_user_interface_idiom () = = Uiuserinterfaceidiompad)
/** to judge whether it is a real machine or a simulator */
#if Target_os_iphone
Real Machine
#endif
#if Target_iphone_simulator
Analog device
#endif
#pragma mark-abbreviation
#define Kapplication [UIApplication sharedapplication]
#define Kkeywindow [UIApplication Sharedapplication].keywindow
#define Kappdelegate [UIApplication sharedapplication].delegate
#define KUSERDEFAULTS [Nsuserdefaults Standarduserdefaults]
#define Knotificationcenter [Nsnotificationcenter Defaultcenter]
#pragma mark-Get relevant information
/** App Version number */
#define Kappversion [[[NSBundle Mainbundle] infodictionary] objectforkey:@ "cfbundleshortversionstring"]
/** System Version Number */
#define Ksystemversion [[Uidevice Currentdevice] systemversion]
/** get the current language */
#define KCURRENTLANGUAGE ([[Nslocale preferredlanguages] objectatindex:0])
/** get the Sandbox document path */
#define Kdocumentpath [Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) FirstObject]
/** Get Sandbox temp path */
#define Ktemppath nstemporarydirectory ()
/** Get the Sandbox cache path */
#define Kcachepath [Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES) FirstObject]
/** Get system time stamp */
#define Getcurenttime [NSString stringwithformat:@ "%ld", (long) [[NSDate Date] timeIntervalSince1970]]
/** Screen Resolution */
#define Screen_resolution (Screen_width * screen_height * ([UIScreen Mainscreen].scale))
Developing common macros-IOS