RLMObjectSchema.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 RLMProperty;
  21. /**
  22. This class represents Realm model object schemas.
  23. When using Realm, `RLMObjectSchema` instances allow performing migrations and
  24. introspecting the database's schema.
  25. Object schemas map to tables in the core database.
  26. */
  27. @interface RLMObjectSchema : NSObject<NSCopying>
  28. #pragma mark - Properties
  29. /**
  30. An array of `RLMProperty` instances representing the managed properties of a class described by the schema.
  31. @see `RLMProperty`
  32. */
  33. @property (nonatomic, readonly, copy) NSArray<RLMProperty *> *properties;
  34. /**
  35. The name of the class the schema describes.
  36. */
  37. @property (nonatomic, readonly) NSString *className;
  38. /**
  39. The property which serves as the primary key for the class the schema describes, if any.
  40. */
  41. @property (nonatomic, readonly, nullable) RLMProperty *primaryKeyProperty;
  42. #pragma mark - Methods
  43. /**
  44. Retrieves an `RLMProperty` object by the property name.
  45. @param propertyName The property's name.
  46. @return An `RLMProperty` object, or `nil` if there is no property with the given name.
  47. */
  48. - (nullable RLMProperty *)objectForKeyedSubscript:(NSString *)propertyName;
  49. /**
  50. Returns whether two `RLMObjectSchema` instances are equal.
  51. */
  52. - (BOOL)isEqualToObjectSchema:(RLMObjectSchema *)objectSchema;
  53. @end
  54. NS_ASSUME_NONNULL_END