BGToolMacro.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // BGToolMacro.h
  3. // BuguLive
  4. //
  5. // Created by xfg on 16/8/3.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. // 工具宏
  8. #ifndef FWToolMacro_h
  9. #define FWToolMacro_h
  10. // Integer转String
  11. #define StringFromInteger(i) [NSString stringWithFormat:@"%@",@(i)]
  12. // Int转String
  13. #define StringFromInt(i) [NSString stringWithFormat:@"%@",@(i)]
  14. //数据验证
  15. #define StrValid(f) (f!=nil && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""])
  16. #define SafeStr(f) (StrValid(f) ? f:@"")
  17. //拼接字符串
  18. #define NSStringFormat(format,...) [NSString stringWithFormat:format,##__VA_ARGS__]
  19. // 角度与弧度转换
  20. #define degreesToRadian(x) (M_PI * (x) / 180.0)
  21. #define radianToDegrees(x) (180.0 * (x) / M_PI)
  22. // 获取图片资源
  23. #define kFWGetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]
  24. // 在主线程上运行
  25. #define kDispatchMainThread(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);
  26. // 开启异步线程
  27. #define kDispatchGlobalQueueDefault(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);
  28. #endif /* FWToolMacro_h */