//appdelegate#defineAppdelegate [(appdelegate*) [uiapplication Sharedapplication] delegate]//----------------------System device-related----------------------------//Get device screen size#defineScreen_width ([UIScreen mainscreen].bounds.size.width)#defineScreen_height ([UIScreen mainscreen].bounds.size.height)//Application Dimensions#defineapp_width [[UIScreen mainscreen]applicationframe].size.width#defineapp_height [[UIScreen mainscreen]applicationframe].size.height//Get System version#defineios_version [[[Uidevice Currentdevice] systemversion] floatvalue]#definecurrentsystemversion [[Uidevice Currentdevice] systemversion]#defineIsIOS4 ([[[Uidevice Currentdevice] systemversion] intvalue]==4)#defineIsIOS5 ([[[Uidevice Currentdevice] systemversion] intvalue]==5)#defineIsIOS6 ([[[Uidevice Currentdevice] systemversion] intvalue]==6)#defineIsIOS7 ([[[Uidevice Currentdevice] systemversion] intvalue]==7)#defineIsIOS8 ([[[Uidevice Currentdevice] systemversion] intvalue]==8)#defineIsIOS9 ([[[Uidevice Currentdevice] systemversion] intvalue]==9)#defineISIOS10 ([[[Uidevice Currentdevice] systemversion] intvalue]==10)#defineISIOS11 ([[[Uidevice Currentdevice] systemversion] intvalue]==11)#defineIsAfterIOS4 ([[[Uidevice Currentdevice] systemversion] intvalue]>4)#defineIsAfterIOS5 ([[[Uidevice Currentdevice] systemversion] intvalue]>5)#defineIsAfterIOS6 ([[[Uidevice Currentdevice] systemversion] intvalue]>6)#defineIsAfterIOS7 ([[[Uidevice Currentdevice] systemversion] intvalue]>7)#defineIsAfterIOS8 ([[[Uidevice Currentdevice] systemversion] intvalue]>8)#defineIsAfterIOS9 ([[[Uidevice Currentdevice] systemversion] intvalue]>9)#defineISAFTERIOS10 ([[[Uidevice Currentdevice] systemversion] intvalue]>10)#defineISAFTERIOS11 ([[[Uidevice Currentdevice] systemversion] intvalue]>11)//get the current language#defineCurrentlanguage ([[Nslocale preferredlanguages] objectatindex:0])//determine if the retina screen, whether the device is%fhone 5, is an ipad#defineIsretina ([UIScreen instancesrespondtoselector: @selector (currentmode)]? Cgsizeequaltosize (Cgsizemake (640, 960), [[UIScreen Mainscreen] currentmode].size): NO)#defineIPhone5 ([UIScreen instancesrespondtoselector: @selector (currentmode)]? Cgsizeequaltosize (Cgsizemake (640, 1136), [[UIScreen Mainscreen] currentmode].size): NO)#defineIspad (ui_user_interface_idiom () = = Uiuserinterfaceidiompad)//Judging whether it's a real machine or a simulator#ifTarget_os_iphone//IPhone Device#endif#ifTarget_iphone_simulator//IPhone Simulator#endif//----------------------System device-related----------------------------//----------------------Memory-related----------------------------//Nsuserdefaults#defineUserdefauleset (Value,key) [[Nsuserdefaults Standarduserdefaults]setobject:value Forkey:key];#defineUserdefauleobject (key) [[Nsuserdefaults Standarduserdefaults]objectisforcedforkey:key];#defineUserdefauleremove (key) [[Nsuserdefaults Standarduserdefaults]removeobjectforkey:key];//Notice#defineNotificationadd (Action,name) [[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (action:) Name:name Object:nil];#defineNotificationpost (name,dict) [[Nsnotificationcenter defaultcenter]postnotificationname:name Object:nil UserInfo: DICT];#defineNotificationremove (name) [[Nsnotificationcenter defaultcenter]removeobserver:self name:name Object:nil];//use arc and do not use arc#if__has_feature (OBJC_ARC)//Compiling with ARC#else//Compiling without ARC#endif//releasing an object#defineSafe_delete (P) if (p) {[P release], p = nil;}#defineSafe_release (x) [x Release];x=nil//----------------------Memory-related----------------------------//----------------------Pictures related to----------------------------//reading Local pictures#defineLoadImage (File,ext) [UIImage imagewithcontentsoffile:[[nsbundle mainbundle]pathforresource:file OfType:ext]//Defining UIImage Objects#defineIMAGE (A) [UIImage imagewithcontentsoffile:[[nsbundle Mainbundle] pathforresource:a Oftype:nil]//Defining UIImage Objects#defineImagenamed (_pointer) [UIImage Imagenamed:_pointer]//stretchable Pictures#defineResizableimage (Name,top,left,bottom,right) [[UIImage Imagenamed:name] Resizableimagewithcapinsets: Uiedgeinsetsmake (Top,left,bottom,right)]#defineResizableimagewithmode (Name,top,left,bottom,right,mode) [[UIImage Imagenamed:name] Resizableimagewithcapinsets: Uiedgeinsetsmake (top,left,bottom,right) Resizingmode:mode]//The first two macro definitions are recommended, with higher performance than the latter//----------------------Pictures related to----------------------------//----------------------Color-related---------------------------//RGB color conversion (16 binary->10)#defineUicolorfromrgb (rgbvalue) [Uicolor colorwithred: ((float) ((Rgbvalue & 0xFF0000) >>))/255.0 Green: ((float) ( (Rgbvalue & 0xff00) >> 8)/255.0 Blue: ((float) (Rgbvalue & 0xFF))/255.0 alpha:1.0]//Get RGB color#defineRGBA (r,g,b,a) [Uicolor colorwithred:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]#defineRGB (r,g,b) RGBA (r,g,b,1.0f)//Background Color#defineBackground_color [Uicolor colorwithred:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]//Clear Background color#defineClearcolor [Uicolor Clearcolor]//----------------------Color-related--------------------------//----------------------Other----------------------------//definition of Founder's bold and simplified body#defineFONT (F) [Uifont fontwithname:@ "fzhtjw--gb1-0" size:f]//file//reads the text content of the file, the default encoding is UTF-8#defineFilestring (Name,ext) [[NSString alloc] Initwithcontentsoffile:[[nsbundle Mainbundle] Pathforresource: (name) OfType: ( EXT)] Encoding:nsutf8stringencoding Error:nil]#defineFiledictionary (Name,ext) [[Nsdictionary alloc] Initwithcontentsoffile:[[nsbundle Mainbundle] PathForResource: (name) OfType: (EXT)]]#defineFilearray (Name,ext) [[Nsarray alloc] Initwithcontentsoffile:[[nsbundle Mainbundle] Pathforresource: (name) OfType: (ex T)]]//g-c-d#defineBack (block) Dispatch_async (dispatch_get_global_queue (dispatch_queue_priority_default, 0), block)#defineMAIN (Block) Dispatch_async (Dispatch_get_main_queue (), block)//Alert#defineALERT (msg) [[[Uialertview alloc] initwithtitle:nil message:msg delegate:nil cancelbuttontitle:@ "OK" otherbuttontitles : nil] show]//get radians from angle get angle#defineDegreestoradian (x) (M_PI * (x)/180.0)#defineRadiantodegrees (Radian) (radian*180.0)/(M_PI)//----------------------Other-------------------------------//----------------------View-related----------------------------//set the text or picture you want to paste#definePastestring (String) [[Uipasteboard Generalpasteboard] setstring:string];#definePasteimage (image) [[Uipasteboard Generalpasteboard] setimage:image];//gets the x, y coordinate point of the left top of the view#defineView_tx (view) (view.frame.origin.x)#defineView_ty (view) (VIEW.FRAME.ORIGIN.Y)//get the x, y coordinate point of the right bottom of the view#defineVIEW_BX (view) (view.frame.origin.x + view.frame.size.width)#defineView_by (view) (VIEW.FRAME.ORIGIN.Y + view.frame.size.height)//get the dimensions of the view: width, height#defineView_w (view) (View.frame.size.width)#defineView_h (view) (View.frame.size.height)//get the x, y coordinate point of frame#defineFrame_tx (frame) (frame.origin.x)#defineFrame_ty (frame) (FRAME.ORIGIN.Y)//get the frame width, height#defineFrame_w (frame) (frame.size.width)#defineFrame_h (frame) (frame.size.height)//----------------------View-related----------------------------//---------------------Print Log--------------------------//print Log in debug mode, current line, function name#ifDEBUG#defineDLog (FORMAT, ...) fprintf (stderr, "\nfunction:%s line:%d content:%s\n", __function__, __line__, [[NSString Stringwithformat:format, # #__VA_ARGS__] utf8string]);#else#defineNSLog (FORMAT, ...) nil#endif//Debug mode print log, current line, function name and pop up a warning#ifdefdebug# define Wdlog (FMT, ...) {Uialertview*alert = [[Uialertview alloc] initwithtitle:[nsstring stringWithFormat:@"%s\n [line%d]", __pretty_function__, __line__] message:[nsstring stringwithformat:fmt, # #__VA_ARGS__]Delegate: Nil Cancelbuttontitle:@"Ok"Otherbuttontitles:nil]; [Alert show]; }#else# define NSLOG (...)#endif//Print Frame#defineLogframe (frame) NSLog (@ "frame[x=%.1f,y=%.1f,w=%.1f,h=%.1f", Frame.origin.x,frame.origin.y,frame.size.width, Frame.size.height)//Print Point#defineLogpoint (point) NSLog (@ "point[x=%.1f,y=%.1f]", POINT.X,POINT.Y)//---------------------Print Log--------------------------
The macro # define that IOS uses