RLMValue

Objective-C

@protocol RLMValue

Swift

protocol RLMValue

RLMValue is a property type which represents a polymorphic Realm value. This is similar to the usage of AnyObject / Any in Swift.

 // A property on `MyObject`
 @property (nonatomic) id<RLMValue> myAnyValue;

 // A property on `AnotherObject`
 @property (nonatomic) id<RLMValue> myAnyValue;

 MyObject *myObject = [MyObject createInRealm:realm withValue:@[]];
 myObject.myAnyValue = @1234; // underlying type is NSNumber.
 myObject.myAnyValue = @"hello"; // underlying type is NSString.
 AnotherObject *anotherObject = [AnotherObject createInRealm:realm withValue:@[]];
 myObject.myAnyValue = anotherObject; // underlying type is RLMObject.

The following types conform to RLMValue:

NSData NSDate NSNull NSNumber NSUUID NSString RLMObject RLMObjectId RLMDecimal128`