FLEXRealmDatabaseManager.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // FLEXRealmDatabaseManager.m
  3. // FLEX
  4. //
  5. // Created by Tim Oliver on 28/01/2016.
  6. // Copyright © 2016 Realm. All rights reserved.
  7. //
  8. #import "FLEXRealmDatabaseManager.h"
  9. //#if __has_include("<Realm/Realm.h>")
  10. #import <Realm/Realm.h>
  11. @interface FLEXRealmDatabaseManager ()
  12. @property (nonatomic, copy) NSString *path;
  13. @property (nonatomic, strong) RLMRealm *realm;
  14. @end
  15. @implementation FLEXRealmDatabaseManager
  16. - (instancetype)initWithPath:(NSString*)aPath
  17. {
  18. self = [super init];
  19. if (self) {
  20. _path = aPath;
  21. }
  22. return self;
  23. }
  24. - (BOOL)open
  25. {
  26. RLMRealmConfiguration *configuration = [RLMRealmConfiguration defaultConfiguration];
  27. configuration.dynamic = YES;
  28. configuration.path = self.path;
  29. NSError *error = nil;
  30. self.realm = [RLMRealm realmWithConfiguration:configuration error:&error];
  31. return (error == nil);
  32. }
  33. - (NSArray *)queryAllTables
  34. {
  35. NSMutableArray *allTables = [NSMutableArray array];
  36. RLMSchema *schema = self.realm.schema;
  37. for (RLMObjectSchema *objectSchema in schema.objectSchema) {
  38. if (objectSchema.className == nil) {
  39. continue;
  40. }
  41. NSDictionary *dictionary = @{@"name":objectSchema.className};
  42. [allTables addObject:dictionary];
  43. }
  44. return allTables;
  45. }
  46. - (NSArray *)queryAllColumnsWithTableName:(NSString *)tableName
  47. {
  48. return nil;
  49. }
  50. - (NSArray *)queryAllDataWithTableName:(NSString *)tableName
  51. {
  52. return nil;
  53. }
  54. @end
  55. //#endif