协议

以下协议在全球范围内可用。

使用 Apple 扩展登录

RLMBSON

RLMValue

  • RLMValue 是一种表示多态 Realm 值的属性类型。 这类似于 Swift 中AnyObject / Any的用法。

     // 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.
    

    以下类型符合 RLMValue:

    NSData NSDate NSNull NSNumber NSUUID NSString RLMObject RLMObjectId RLMDecimal 128 RLMDictionary RLMArray NSArray NSDictionary`

    查看更多

    声明

    Objective-C

    @protocol RLMValue

    Swift

    protocol RLMValue