1. 判断是否是iPad
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
2. iOS版本判断
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_5_1
[navigationController.navigationBar addSubview:imageView];
#else
[navigationController.navigationBar insertSubview:imageView atIndex:0];
#endif
3. 自定log 调试用
#define showLogInfo 1
#if showLogInfo
# define DLog(...) NSLog(__VA_ARGS__)
#else
# define DLog(...)
#endif
4. 各目录路径获取
// 获取沙盒主目录路径 NSString *homeDir = NSHomeDirectory(); // 获取Documents目录路径 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docDir = [paths objectAtIndex:0]; // 获取Caches目录路径 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cachesDir = [paths objectAtIndex:0]; // 获取tmp目录路径 NSString *tmpDir = NSTemporaryDirectory();