NSString+FFDBExtern.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // NSString+FFDBExtern.m
  3. // FFDB
  4. //
  5. // Created by Fidetro on 2017/7/23.
  6. // Copyright © 2017年 Fidetro. All rights reserved.
  7. //
  8. #import "NSString+FFDBExtern.h"
  9. #import "FFDataBaseModel+Custom.h"
  10. @implementation NSString (FFDBExtern)
  11. + (NSString *)stringWithColumns:(NSArray <NSString *>*)columns
  12. {
  13. NSMutableString *columnsString = [NSMutableString string];
  14. for (NSInteger index = 0; index < columns.count; index++)
  15. {
  16. NSString *column = columns[index];
  17. if (index == 0)
  18. {
  19. [columnsString appendString:column];
  20. }
  21. else
  22. {
  23. [columnsString appendFormat:@",%@",column];
  24. }
  25. }
  26. return [columnsString copy];
  27. }
  28. + (NSString *)stringWithTableNameOfClasses:(NSArray <Class>*)dbClasses
  29. {
  30. NSMutableString *classesString = [NSMutableString string];
  31. for (NSInteger index = 0; index < dbClasses.count; index++)
  32. {
  33. Class class = dbClasses[index];
  34. NSString *tableName = [class tableName];
  35. if (index == 0)
  36. {
  37. [classesString appendFormat:@"`%@`",tableName];
  38. }
  39. else
  40. {
  41. [classesString appendFormat:@",`%@`",tableName];
  42. }
  43. }
  44. return [classesString copy];
  45. }
  46. /**
  47. fix property NSUInteger bug
  48. */
  49. - (unsigned long long)unsignedLongLongValue
  50. {
  51. return self.longLongValue;
  52. }
  53. /**
  54. fix bool with 32 bit on ios problem https://stackoverflow.com/questions/31267325/bool-with-64-bit-on-ios/31270249#31270249
  55. */
  56. - (BOOL)charValue
  57. {
  58. if ([self boolValue] == YES)
  59. {
  60. return YES;
  61. }else
  62. {
  63. return NO;
  64. }
  65. }
  66. @end