简体   繁体   中英

class_copyPropertyList not working with RLMObject

I am trying to get the property list of an RLMObject programmatically like this:

MyRLMObject *myRLMObject = [[MyRLMObject alloc] init];
unsigned int count;
objc_property_t *properties = class_copyPropertyList([myRLMObject class], &count);

but it returns null.

This works well with normal classes derived from NSObject.

I put a breakpoint and found that myRLMObject is actually structured as

  (RLMStandalone_MyRLMObject *) 0x12c5c9cf0
    MyRLMObject
      RLMObject
      _strName = (NSString *) nil
      _strId = (NSString *) nil

("strName" and "strId" are the properties I defined and want to get from the list.)

With a normal class derived from NSObject, I got this

  (MyNSObject *) 0x12c5cab40
    NSObject
    _strName = (NSString *) nil
    _strId = (NSString *) nil

I think the reason should be that Realm added a "RLMStandalone_MyRLMObject" outside the class structure and caused class_copyPropertyList fail to work.

Is there any workaround for this problem? Thanks in advance.

我认为问题是因为RLMObject具有动态属性,这意味着它们将在运行时被创建并添加到每个对象,并且您不知道何时会发生。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM