#import <Availability.h> #ifndef __IPHONE_5_0 #warning "This project uses features only available in iOS SDK 5.0 and later." #endif #ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #endif
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width//获取屏幕宽度,兼容性测试 #define ScreenHeight [[UIScreen mainScreen] bounds].size.height//获取屏幕高度,兼容性测试 #define HOST @"www.baidu.com" #define POST 8080
判断应用的iOS版本app
#ifdef DEBUG // 调试状态, 打开LOG功能 #define GJLog(...) NSLog(@"\nclass:\t%@ \nmethod: \t%s: \nline:\t%d",[self class],__func__,__LINE__);NSLog(__VA_ARGS__) #else #define GJLog(...) #endif
在程序中输出就须要调用GJLog,这样能够实现只在调试状态下输出,发布状态下没有输出,而且每一个输出都有行号
函数
输出效果以下所示测试
2015-08-24 11:47:37.247 Weibo[2699:72101] class: AppDelegate
method: -[AppDelegate application:didFinishLaunchingWithOptions:]:
line: 24ui
2015-08-24 11:47:37.248 Weibo[2699:72101] abcvspa
Command + N 而后在Other里面选择PCH File调试
常量的管理,用这个会更好,第一效率高,第二能够检查语法
内存
http://www.xiaoyaoli.com/?p=929
get
判断系统是否支持一些功能
#if !__has_feature(objc_arc) //当没有使用自动内存管理的时候采用的代码 -(void) release{ } #endif