RLMSchema.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2014 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import <Foundation/Foundation.h>
  19. NS_ASSUME_NONNULL_BEGIN
  20. @class RLMObjectSchema;
  21. /**
  22. `RLMSchema` instances represent collections of model object schemas managed by a Realm.
  23. When using Realm, `RLMSchema` instances allow performing migrations and
  24. introspecting the database's schema.
  25. Schemas map to collections of tables in the core database.
  26. */
  27. @interface RLMSchema : NSObject<NSCopying>
  28. #pragma mark - Properties
  29. /**
  30. An `NSArray` containing `RLMObjectSchema`s for all object types in the Realm.
  31. This property is intended to be used during migrations for dynamic introspection.
  32. @see `RLMObjectSchema`
  33. */
  34. @property (nonatomic, readonly, copy) NSArray<RLMObjectSchema *> *objectSchema;
  35. #pragma mark - Methods
  36. /**
  37. Returns an `RLMObjectSchema` for the given class name in the schema.
  38. @param className The object class name.
  39. @return An `RLMObjectSchema` for the given class in the schema.
  40. @see `RLMObjectSchema`
  41. */
  42. - (nullable RLMObjectSchema *)schemaForClassName:(NSString *)className;
  43. /**
  44. Looks up and returns an `RLMObjectSchema` for the given class name in the Realm.
  45. If there is no object of type `className` in the schema, an exception will be thrown.
  46. @param className The object class name.
  47. @return An `RLMObjectSchema` for the given class in this Realm.
  48. @see `RLMObjectSchema`
  49. */
  50. - (RLMObjectSchema *)objectForKeyedSubscript:(NSString *)className;
  51. /**
  52. Returns whether two `RLMSchema` instances are equivalent.
  53. */
  54. - (BOOL)isEqualToSchema:(RLMSchema *)schema;
  55. @end
  56. NS_ASSUME_NONNULL_END