iOS开发中需要注意的一些小细节

  1. Xcode 项目中我们可以使用 ARC 和非 ARC 的混合模式。

    如果你的项目使用的非 ARC 模式,则为 ARC 模式的代码文件加入 -fobjc-arc 标签。

    如果你的项目使用的是 ARC 模式,则为非 ARC 模式的代码文件加入 -fno-objc-arc 标签。


    2 使用数据库注意导入路径:/usr/include/libxml2


    3  打开终端(在应用程序->实用工具)

    输入以下命令:彻底删除openFire

    sudo rm -rf /Library/PreferencePanes/Openfire.prefPane

    sudo rm -rf /usr/local/openfire

    sudo rm -rf /Library/LaunchDaemons/org.jivesoftware.openfire.plist


    彻底删除spark

    sudo rm -rf /Applications/spark.app

    彻底删除XAMPP

    /Applications/XAMPP/xamppfiles/xampp stop   停止XAMPP服务

    sudo rm -rf /Applications/xampp  彻底删除XAMPP

  2. // 安全释放  
  3. #define RELEASE_SAFELY(__Pointer) do{[__Pointer release],__Pointer = nil;} while(0)  
  4.   
  5. // 屏幕的物理高度  
  6. #define  ScreenHeight  [UIScreen mainScreen].bounds.size.height  
  7.   
  8. // 屏幕的物理宽度  
  9. #define  ScreenWidth   [UIScreen mainScreen].bounds.size.width  
  10.   
  11. // 调试  
  12. #define NSLOG_FUNCTION NSLog(@"%s,%d",__FUNCTION__,__LINE__)  
  13.   
  14. //----------------------图片————————————————————————————————————————  
  15.     
  16. //读取本地图片    
  17. #define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]    
  18.     
  19. //定义UIImage对象    
  20. #define IMAGE(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]    
  21.     
  22. //定义UIImage对象    
  23. #define ImageNamed(_pointer) [UIImage imageNamed:_pointer]   
  24.   
  25. //———————————————————————颜色类———————————————————————————  
  26. // rgb颜色转换(16进制->10进制)    
  27. #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]    
  28.     
  29. //带有RGBA的颜色设置    
  30. #define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]    
  31.     
  32. // 获取RGB颜色    
  33. #define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]    
  34. #define RGB(r,g,b) RGBA(r,g,b,1.0f)    
  35.     
  36. //背景色    
  37. #define BACKGROUND_COLOR [UIColor colorWithRed:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]    
  38.     
  39. //清除背景色    
  40. #define CLEARCOLOR [UIColor clearColor]    
  41.     
  42. #pragma mark - color functions    
  43. #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]    
  44. #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]    
  45.   
  46. //———————————————————————TAG宏———————————————————————————
  47. //viewWithTag  
  48. #define VIEWWITHTAG(_OBJECT, _TAG)    [_OBJECT viewWithTag : _TAG]   
  1. //———————————————————————单例模式宏———————————————————————————
  2.       //.h文件处的声明  
  3. #define DEFINE_SINGLETON_FOR_HEADER(className) \  
  4. \  
  5. + (className *)shared##className;  
  6.   
  7.       //.m文件处的声明  
  8. #define DEFINE_SINGLETON_FOR_CLASS(className) \  
  9. \  
  10. + (className *)shared##className { \  
  11.     static className *shared##className = nil; \  
  12.     static dispatch_once_t onceToken; \  
  13.     dispatch_once(&onceToken, ^{ \  
  14.         shared##className = [[self alloc] init]; \  
  15.     }); \  
  16.     return shared##className; \  
  17. }  
  18. //———————————————————————单例模式——————————————————————————— 
  19. static DataBaseHandle * handle = nil;  
  20. + (DataBaseHandle *)shareInstance  
  21. {  
  22.     @synchronized(self){  
  23.         if (!handle) {  
  24.             handle = [[DataBaseHandle alloc] init];  
  25.         }  
  26.     }  
  27.     return handle;  
  28. }  
  29. —————————————不用你把所有NSLog的删除或注释,直接修改#if 判断的值就行了(1执行,0不执行)——————————————  
  30. #if 1  
  31.   
  32. #define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);  
  33. #else  
  34.   
  35. #define NSLog(FORMAT, ...) nil  
  36.   
  37. #endif  
  38.   
  39.   
  40. #define NEED_OUTPUT_LOG                     0  
  41. #if NEED_OUTPUT_LOG  
  42.   
  43.     #define SLog(xx, ...)   NSLog(xx, ##__VA_ARGS__)  
  44.     #define SLLog(xx, ...)  NSLog(@"%s(%d): " xx, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)  
  45.   
  46.     #define SLLogRect(rect) \  
  47.     SLLog(@"%s x=%f, y=%f, w=%f, h=%f", #rect, rect.origin.x, rect.origin.y, \  
  48.     rect.size.width, rect.size.height)  
  49.   
  50.     #define SLLogPoint(pt) \  
  51.     SLLog(@"%s x=%f, y=%f", #pt, pt.x, pt.y)  
  52.   
  53.     #define SLLogSize(size) \  
  54.     SLLog(@"%s w=%f, h=%f", #size, size.width, size.height)  
  55.   
  56.     #define SLLogColor(_COLOR) \  
  57.     SLLog(@"%s h=%f, s=%f, v=%f", #_COLOR, _COLOR.hue, _COLOR.saturation, _COLOR.value)  
  58.   
  59.     #define SLLogSuperViews(_VIEW) \  
  60.     { for (UIView* view = _VIEW; view; view = view.superview) { SLLog(@"%@", view); } }  
  61.   
  62.     #define SLLogSubViews(_VIEW) \  
  63.     { for (UIView* view in [_VIEW subviews]) { SLLog(@"%@", view); } }  
  64.   
  65. #else  
  66.   
  67.     #define SLog(xx, ...)  ((void)0)  
  68.     #define SLLog(xx, ...)  ((void)0)  
  69.   
  70. #endif  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值