iphone 常用预编译代码
http://blog.sina.com.cn/u/2079395307??iphone和andorid開發(fā)博客
1.自定義DLog輸出
#ifdef DEBUGLOG
# ? define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# ? define DLog(...)
#endif
2.判斷設(shè)備ios版本
#define SYSTEM_VERSION_GREATER_THAN(v)? ? ? ? ? ? ? ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)? ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ? ? ? ? ? ? ? ? ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ? ? ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
3.判斷設(shè)備是否支持retina
#ifndef ImageShowcase_Utility_h
#define ImageShowcase_Utility_h
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,960), [[UIScreen mainScreen] currentMode].size) : NO)
#endif
4.適配iphone5的屏幕
//adaptive iphone5 macro
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhoneAppFrame [[UIScreen mainScreen] applicationFrame]
#define iPhoneScreenBounds [[UIScreen mainScreen] bounds]
5.Debug 標(biāo)記
??/*!
?? For debugging:
?? Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode).?
?? Then go in the "Arguments" tab. You can add the following environment variables:
? ?
?? Default: ? Set to:
?? NSDebugEnabled? ? ? ? ? ? ? ? ? ? ? ? NO ? ? ? "YES"
?? NSZombieEnabled ? ? ? ? ? ? ? ? ? ? ? NO ? ? ? "YES"
?? NSDeallocateZombies ? ? ? ? ? ? ? ? ? NO ? ? ? "YES"
?? NSHangOnUncaughtException ? ? ? ? ? ? NO ? ? ? "YES"
? ?
?? NSEnableAutoreleasePool? ? ? ? ? ? ? YES ? ? ? "NO"
?? NSAutoreleaseFreedObjectCheckEnabled? NO ? ? ? "YES"
?? NSAutoreleaseHighWaterMark ? ? ? ? ? ? 0 ? ? ? non-negative integer
?? NSAutoreleaseHighWaterResolution ? ? ? 0 ? ? ? non-negative integer
? ?
?? For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html
? ?
?? For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
?? */
6. ARC宏定義#ifndef MB_STRONG
#if __has_feature(objc_arc)
? ? #define MB_STRONG strong
#else
? ? #define MB_STRONG retain
#endif
#endif
#ifndef MB_WEAK
#if __has_feature(objc_arc_weak)
? ? #define MB_WEAK weak
#elif __has_feature(objc_arc)
? ? #define MB_WEAK unsafe_unretained
#else
? ? #define MB_WEAK assign
#endif
#endif
7.ARC (Automatic Reference Counting)
JMImageCache?uses?Automatic Reference Counting (ARC). If your project doesn't use ARC, you will need to set the?-fobjc-arccompiler flag on all of the?JMImageCache?source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. In the "Compiler Flags" column, set?-fobjc-arc?for each of the?JMImageCache?source files.
ARC (Automatic Reference Counting)
JMImageCache?uses?Automatic Reference Counting (ARC). If your project doesn't use ARC, you will need to set the?-fobjc-arccompiler flag on all of the?JMImageCache?source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. In the "Compiler Flags" column, set?-fobjc-arc?for each of the?JMImageCache?source files.
ARC (Automatic Reference Counting)
JMImageCache?uses?Automatic Reference Counting (ARC). If your project doesn't use ARC, you will need to set the?-fobjc-arccompiler flag on all of the?JMImageCache?source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. In the "Compiler Flags" column, set?-fobjc-arc?for each of the?JMImageCache?source files.
版權(quán)聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。
轉(zhuǎn)載于:https://www.cnblogs.com/zsw-1993/archive/2012/11/02/4880683.html
總結(jié)
以上是生活随笔為你收集整理的iphone 常用预编译代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 通过Maven去运行单元测试
- 下一篇: EditPlus 3.5 版已经发布