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
RLMDictionary
RLMArray
NSArray
NSDictionary`
-
Deprecated
Use
rlm_anyValueType
instead, which includes collection types as wellDescribes the type of property stored.
Declaration
Objective-C
@property (readonly) RLMAnyValueType rlm_valueType;
Swift
var rlm_valueType: RLMAnyValueType { get }
-
Describes the type of property stored.
Declaration
Objective-C
@property (readonly) RLMAnyValueType rlm_anyValueType;
Swift
var rlm_anyValueType: RLMAnyValueType { get }