RLMEmbeddedObject.mm 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2020 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 "RLMEmbeddedObject.h"
  19. #import "RLMObject_Private.hpp"
  20. #import "RLMSchema_Private.h"
  21. @implementation RLMEmbeddedObject
  22. // synthesized in RLMObjectBase but redeclared here for documentation purposes
  23. @dynamic invalidated, realm, objectSchema;
  24. #pragma mark - Designated Initializers
  25. - (instancetype)init {
  26. return [super init];
  27. }
  28. #pragma mark - Convenience Initializers
  29. - (instancetype)initWithValue:(id)value {
  30. if (!(self = [self init])) {
  31. return nil;
  32. }
  33. RLMInitializeWithValue(self, value, RLMSchema.partialPrivateSharedSchema);
  34. return self;
  35. }
  36. #pragma mark - Subscripting
  37. - (id)objectForKeyedSubscript:(NSString *)key {
  38. return RLMObjectBaseObjectForKeyedSubscript(self, key);
  39. }
  40. - (void)setObject:(id)obj forKeyedSubscript:(NSString *)key {
  41. RLMObjectBaseSetObjectForKeyedSubscript(self, key, obj);
  42. }
  43. #pragma mark - Other Instance Methods
  44. - (BOOL)isEqualToObject:(RLMObjectBase *)object {
  45. return [object isKindOfClass:RLMObjectBase.class] && RLMObjectBaseAreEqual(self, object);
  46. }
  47. - (instancetype)freeze {
  48. return RLMObjectFreeze(self);
  49. }
  50. - (instancetype)thaw {
  51. return RLMObjectThaw(self);
  52. }
  53. - (RLMNotificationToken *)addNotificationBlock:(RLMObjectChangeBlock)block {
  54. return RLMObjectAddNotificationBlock(self, block, nil, nil);
  55. }
  56. - (RLMNotificationToken *)addNotificationBlock:(RLMObjectChangeBlock)block queue:(dispatch_queue_t)queue {
  57. return RLMObjectAddNotificationBlock(self, block, nil, queue);
  58. }
  59. - (RLMNotificationToken *)addNotificationBlock:(RLMObjectChangeBlock)block keyPaths:(NSArray<NSString *> *)keyPaths {
  60. return RLMObjectAddNotificationBlock(self, block, keyPaths, nil);
  61. }
  62. - (RLMNotificationToken *)addNotificationBlock:(RLMObjectChangeBlock)block
  63. keyPaths:(NSArray<NSString *> *)keyPaths
  64. queue:(dispatch_queue_t)queue {
  65. return RLMObjectAddNotificationBlock(self, block, keyPaths, queue);
  66. }
  67. + (NSString *)className {
  68. return [super className];
  69. }
  70. #pragma mark - Default values for schema definition
  71. + (NSString *)primaryKey {
  72. return nil;
  73. }
  74. + (NSArray *)indexedProperties {
  75. return @[];
  76. }
  77. + (NSDictionary *)linkingObjectsProperties {
  78. return @{};
  79. }
  80. + (NSDictionary *)defaultPropertyValues {
  81. return nil;
  82. }
  83. + (NSArray *)ignoredProperties {
  84. return nil;
  85. }
  86. + (NSArray *)requiredProperties {
  87. return @[];
  88. }
  89. + (bool)_realmIgnoreClass {
  90. return false;
  91. }
  92. + (bool)isEmbedded {
  93. return true;
  94. }
  95. @end